Okay. Let's make a leaderboard stat called XP. We can do this with this script
game.Players.PlayerAdded:connect(function(player)
local folder = Instance.new("Folder",player)
folder.Name = "leaderstats"
local stat = Instance.new("IntValue",folder)
stat.Name = "XP"
end)
Now once a player joins, he has a leaderboard stat named XP.
The following script will award the killer with XP if he has killed someone by using the Humanoid's "Died" event.
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
local tag = character.Humanoid:FindFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
stat.Value = stat.Value + 10
end
end
end)
end)
You can keep the scripts separate for simplicity, or just have both of them in one script.
1 comment
Oh, I didn't even notice you said money as well... But same concept applies, create another Integer Value in the folder named Money/Cash/Whatever you'd like and add to it once they are killed.