Hello! I am trying to make a leaderboard for a game that computes kills, deaths & awards cash the longer a player is in the game.
It works great except the Cash does not begin paying out until the player dies.
I've moved it around and am still running into problems- Any suggestions?
Thanks.
game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent= plr
local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Parent = stats
local deaths = Instance.new("IntValue")
deaths.Name = "Deaths"
deaths.Parent = stats
local score = Instance.new("IntValue")
score.Name = "Cash"
score.Parent = stats
score.Value = 1
plr.CharacterAdded:Connect(function(char)
local humanoid
repeat
humanoid = char:FindFirstChild("Humanoid")
wait()
until humanoid
humanoid.Died:Connect(function()
deaths.Value = deaths.Value + 1
local tag = humanoid:FindFirstChild("creator")
if tag then
local killer = tag.Value
if killer then
killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
end
end
while true do
wait(5)
score.Value = score.Value + 3
end
end)
end)
end)

2 comments
Don't forget to hit "Accept Answer" if this helped you.
Doh! I've been banging my head over this forever. THANK YOU!!!!!!!!!!!!!!!!