generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Question: Died Event

Previous Thread :: Next Thread 
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 05:32 PM
I'm trying to create my first leaderboard... And I'm trying to think of a way where if a person dies, the WO goes up 1, each time the person dies... I'm new to this "leaderboard" stuff, and I thought that I could use the Died event. Except that I don't know much on how to use it:

game.Players.PlayerAdded:connect(function(player)

repeat wait() until player.Character
local leaderstats = Instance.new("IntValue", player)
leaderstats.Name = "leaderstats"
local WOS = Instance.new("IntValue", leaderstats)
WOS.Name = "Wipeouts"
WOS.Value = 0
end)
for i, v in pairs(game.Players:GetChildren()) do
if v:findFirstChild("Humanoid") then
v.Died:connect(function ()
WOS.Value = WOS.Value+1
end)
end
end

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 09:04 PM
Bump

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
30 Nov 2012 09:21 PM
game.Players.PlayerAdded:connect(function(player)

-- repeat wait() until player.Character
wait()
local leaderstats = Instance.new("IntValue", player)
leaderstats.Name = "leaderstats"
local WOS = Instance.new("IntValue", leaderstats)
WOS.Name = "Wipeouts"
WOS.Value = 0

-- Use CharacterAdded
player.CharacterAdded:connect(function(newChar)
wait()
if newChar:FindFirstChild("Humanoid") then
newChar.Humanoid.Died:connect(function()
WOS.Value = WOS.Value + 1
end)
end
end)

end)
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 09:50 PM
Lol, wow! You're a great help! xD Butt I have a question in mind while we're on it... How are KOs calculated when a player kills another?

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 09:51 PM
But*

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
30 Nov 2012 09:51 PM
Typically in gears and most tools, when the player dies, their Humanoids are checked for object values, usually called "creator", then the value is the player who killed the player who died.

¤¤ †KMXD† ¤¤
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
30 Nov 2012 09:53 PM
They're not in gear/most tools*

Tools/gears just instance the objectvalue into the Humanoids.

¤¤ †KMXD† ¤¤
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 09:59 PM
Confused <_> They're not in gear and/or most tools?

And how can you instance the object value into humanoids?

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
30 Nov 2012 10:07 PM
Sorry, in most tools or gears, they instance the objectvalue, the value being the tool user's name, and parent it to the victim's Humanoids.

In leaderboards (for real players) or regular scripts in AIs, when the player (or AI) dies, they check for the victim's Humanoid, and get the killer by using the value of said objectvalue.

¤¤ †KMXD† ¤¤
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 10:12 PM
But how do you change the Value of an Object Value?

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
30 Nov 2012 10:18 PM
ObjectValue.Value = player

And where I said it checks for the name, it's the instance, sorry.

¤¤ †KMXD† ¤¤
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 10:26 PM
Okay, okay... so if I were to script this, would it do something within these lines?:

New IntValue in Leaderstats called Knockouts

Creates an ObjectValue in the Player who Died

Checks which player made the ObjectValue be created

IntValue of Knockouts rise to +1.

I'm still a little confused of what you're trying to say to me. Sorry, I am just really new to these things with leaderboards.

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
30 Nov 2012 10:30 PM
See, the ROBLOX method of finding who killed who is dynamic (not set strictly) because the game isn't strict, simply. You can make most of what you want and leave out what you don't.

The code that creates the ObjectValue 'creator' is in the weapons. If it isn't, you should make it there. They are put into the person who is being attacked's Humanoid object and the value is set as the attacker's Player. That way, in your leaderboard, when you detect someone dying, you can use FindFirstChild to see if there is a creator value in the _dying_ humanoid.

Once you find that value (and if you do) you access the [creator.Value] to get the player who _killed_ the Humanoid that died. You simply add a kill to that value and a wipeout to the player of the dead humanoid.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
30 Nov 2012 10:30 PM
game.Players.PlayerAdded:connect(function(player)

-- repeat wait() until player.Character
wait()
local leaderstats = Instance.new("IntValue", player)
leaderstats.Name = "leaderstats"
local WOS = Instance.new("IntValue", leaderstats)
WOS.Name = "Wipeouts"
WOS.Value = 0

-- Use CharacterAdded
player.CharacterAdded:connect(function(newChar)
wait()
if newChar:FindFirstChild("Humanoid") then
newChar.Humanoid.Died:connect(function()
WOS.Value = WOS.Value + 1
-- Add to KOS
if newChar.Humanoid:FindFirstChild("creator") then
local killer = newChar.Humanoid.creator.Value
killer.leaderstats.KOS.Value = killer.leaderstats.KOS.Value + 1
end

end)
end
end)

end)




Your weapon needs to create an ObjectValue that stores the PLAYER who fires the weapon.


local tag = Instance.new("ObjectValue")
tag.Name = "creator"
tag.Value = Player_Who_Killed
tag.Parent = Player_Being_Killed.Character.Humanoid
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
30 Nov 2012 10:34 PM
You two are total noobs.

¤¤ †KMXD† ¤¤
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 10:37 PM
Thanks guys! xD Another question, what does this: _ mean? I've seen it being used in
variables, and in
for loops. for _,
.


~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
30 Nov 2012 10:39 PM
The index, so if you have 2 objects in Workspace, and run:

    for _, v in pairs(Workspace:GetChildren()) do
      print(_)
    end

It would print 1-5.

¤¤ †KMXD† ¤¤
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
30 Nov 2012 10:39 PM
I can't count. . .

It would print 1 and 2.

¤¤ †KMXD† ¤¤
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
30 Nov 2012 10:41 PM
Jonah,

It has to do with tables. I did an explanation here:

http://www.roblox.com/Forum/ShowPost.aspx?PostID=83206597
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 10:45 PM
Then if _ is an index, what does _ mean?

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 10:46 PM
Oh okay nevermind, I get it.

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
30 Nov 2012 10:46 PM
It's just a variable, people typically use that, or i.

¤¤ †KMXD† ¤¤
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
30 Nov 2012 10:48 PM
Oooohhhh O: Okay, now I do understand xD. I thought that it had a different meaning than letters.

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image