Im actually running it on a script with data store in it which i didn’t include it in for some reason
I’m pretty sure this is happening because you dont make the death value inside of the player like this:
game.Players.PlayerAdded:Connect(function(player)
local deaths = player.leaderstats.Deaths
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
deaths.Value += 1
end)
end)
end)
I already assigned the variable called “deaths” look
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local Deaths = Instance.new("IntValue",leaderstats)
Deaths.Name = "Deaths"
plr.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
Deaths.Value += 1
game.ReplicatedStorage.ServerOofs.Value += 1
end)
end)
try it without the “WaitForChild” for the humanoid.
That basically works the same with WaitForChild the death counter only works for 1 player in the server
I am assuming you haven’t tried this one?
local counter = 0
humanoid.Died:Connect(function()
counter = counter + 1
end)
Credits to this awesome dude: How to make a death counter - #4 by AbandonedRick
His name is @Wqund
Is it a script or local script?
I’m assuming it would be a script.
+=
does not work in Lua. Instead, do:
Deaths.Value = Deaths.Value + 1
game.ReplicatedStorage.ServerOofs.Value = game.ReplicatedStorage.ServerOofs.Value + 1
This is luau, not lua. There are some differences between them including this one.
Totally agreed on that. Tell me if it works.
It does work in lua since the death counter works but only for 1 player try this script for proof
local counter = 0 --Make a variable called counter
while wait(5) do --Make a loop
counter += 1 --Increase the variable called counter by 1 by using +=
print(counter) --Print the counter variable's value
end
Whoops, looks like I was incorrect.
But is there any solution to make it work for other players whatsoever
I just tried your script, and it worked perfectly without any errors. Maybe another script is causing the issue?
Did you try with 2 players? And instead of only resetting them make them fall off the map
I tried it with 3 players, and it still works when they fall off. If it still doesn’t work for you, try using Player.CharacterRemoved
instead of Humanoid.Died
.
Have you tried putting prints under PlayerAdded and CharacterAdded and Died to see if they are firing at all when the player dies?
It does fire but only works for 1 player
Are you testing this in studio or in a published place? It’s possible that when you are testing it with 1 player, PlayerAdded isn’t connected before the player loads in.