|
| 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 |
|
|
|
| 30 Nov 2012 09:04 PM |
Bump
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 30 Nov 2012 09:51 PM |
But*
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 30 Nov 2012 10:12 PM |
But how do you change the Value of an Object Value?
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 30 Nov 2012 10:34 PM |
You two are total noobs.
¤¤ †KMXD† ¤¤ |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 30 Nov 2012 10:39 PM |
I can't count. . .
It would print 1 and 2.
¤¤ †KMXD† ¤¤ |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 30 Nov 2012 10:45 PM |
Then if _ is an index, what does _ mean?
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ |
|
|
| Report Abuse |
|
|
|
| 30 Nov 2012 10:46 PM |
Oh okay nevermind, I get it.
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ |
|
|
| Report Abuse |
|
|
|
| 30 Nov 2012 10:46 PM |
It's just a variable, people typically use that, or i.
¤¤ †KMXD† ¤¤ |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|