Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Problem with my leaderboard?

I made this leaderboard that sets it up, also rewarding 3 tokens and 1 kill. When I kill another player, that doesn't happen. Help?

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
 
    local tokens = Instance.new("IntValue")
    tokens.Name = "Tokens"
    tokens.Value = 0
    tokens.Parent = leaderstats

	local kills = Instance.new("IntValue")
  	kills.Name = "Kills"
	kills.Value = 0
    kills.Parent = leaderstats
       
	player.CharacterAdded:connect(function(chr)
		local chr = player.Character
		chr.Humanoid.Died:connect(function(chr)
			local chr = player.Character
        	local killer = chr.Humanoid:findFirstChild("creator")
        	if killer then
        		killer.leaderstats.Kills.Value = killer.Value.Kills.Value + 1
            	killer.leaderstats.Tokens.Value = killer.leaderstats.Tokens.Value + 3
			end
		end)
	end)
end)

1 answer

the killer's player instance would be killer.Value so:

local plrwhokilled = killer.Value
plrwhokilled.leaderstats.Kills.Value = plrwhokilled.leaderstats.Kills.Value + 1
--and so on

This discussion is preserved as it was. New answers, comments, and votes are closed.