So the question is kind of self explanatory. I thought my script should work, but it doesn't. Here it is:
game.Players.PlayerAdded:connect(function(player) local folder = Instance.new("Folder",player) folder.Name = "leaderstats" local currency1 = Instance.new("IntValue",folder) currency1.Name = "Kills" 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 -- Here tag.Value is the player who killed us, so find their leaderstats local killersLeaderstats = tag.Value:FindFirstChild("leaderstats") if killersLeaderstats then -- Award the Kills to the player that killed us killersLeaderstats.Kills.Value = killersLeaderstats.Kills.Value + 1 end end end end) end) end)
Any idea what the problem is. Hope you can help thanks!
Creator ObjectValue
s are an ancient and badly designed solution for knockout leaderboards. Instead, modify your weapons. When the weapon does damage to a player, check if the player's new health is <= 0
. If so, the player who attacked with the weapon killed the dead player, and you can award them one kill.
Additionally, RBXScriptSignal:connect()
is deprecated, you should prefer RBXScriptSignal:Connect()
.