Does their death add to your count? or only yours?
Only for me since i am the first person to join the server
What I meant was is every death added to your personal count, as the first person.
P1 dies, their count is 1
P2 dies, their count is still 0
does P1 say 2?
Nope P1 still says their count is 1
My death counter still isn’t working
Hi, to make it works! you need to use a RemoteEvent to add a Kill.
+= does work by the way, it doesn’t matter which way a scripter uses.
this worked for me
game.Players.PlayerAdded:Connect(function(player)
local ls = Instance.new("Folder")
ls.Parent = player
ls.Name = "leaderstats"
local d = Instance.new("IntValue")
d.Parent = ls
d.Name = "Deaths"
d.Value = 0
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
z = hum.Died:Connect(function()
-- connect to deaths
d.Value = d.Value + 1 -- add 1 to death value
print("died")
wait()
z:Disconnect()
end)
end)
end)
Try indexing character added and died event connection and disconnect it once player leaves
Like
Table = {}
game.Players.PlayerAdded:Connect(function(player)
Table[player].Leaderstats = Instance.new("Folder")
Table[player].Leaderstats.Parent = player
Table[player].Leaderstats.Name = "leaderstats"
Table[player].Deaths = Instance.new("IntValue")
Table[player].Deaths.Parent = Table[player].Leaderstats
Table[player].Deaths.Name = "Deaths"
Table[player].Deaths.Value = 0
Table[player].CharacterAdded = player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
Table[player].Died = hum.Died:Connect(function()
Table[player].Deaths.Value = Table[player].Deaths.Value + 1 -- add 1 to death value
print("died")
wait()
end)
end)
end)
-- Clean up
game.Players.PlayerRemoving:Connect(function(player)
if Table[player] then
Table[player].Died:Disconnect()
Table[player].Died = nil
Table[player].CharacterAdded:Disconnect()
Table[player].CharacterAdded = nil
Table[player].Deaths = nil
Table[player].Leaderstats = nil
end
end)
I’m currently on mobile
My apologies i was sleeping which means that i couldn’t reply to your replies but i will try them after i get in pc and right now i am currently on mobile
I tried your script with no errors but still works the same
The character:WaitForChild(“Humanoid”).Died:Connect(function()
Deaths.Value += 1
game.ReplicatedStorage.ServerOofs.Value += 1
end) needs to be outside the function
That would give an error saying
Attempt to index nil with character
And its sort of impossible to get the local player from a script in this way
Then something is keeping deaths from being added to.
Print deaths after you add to it, maybe its just the leaderboard that isn’t updating?
I did make it print but it only prints when i die not when others die
And Im sure that game.Players.PlayerAdded
Updates everytime someone joins
It doesn’t “update” exactly, it fires the event so it should be working, try to be the 2nd player that joins and then reset and see if it prints anything different/errors.
I don’t know about it tho i can’t just tell my friends to join my game and then i join it