I am trying to make a deaths counter script for my shooter game, you have a stats section and deaths is one of the stats I wanted to keep track of.
I have tried 2 variations of this script but neither of them seem to work.
Heres the first one, this one is just local side, its placed inside StarterGui
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character:WaitForChild("Humanoid").Died:connect(function()
game.ReplicatedStorage.DataFile[Player.Name].TotalDeaths.Value = game.ReplicatedStorage.DataFile[Player.Name].TotalDeaths.Value + 1
end)
end)
end)
Then I figured it may be a server to local script communication error so I made this one
Local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DeathCounterEvent = ReplicatedStorage:WaitForChild("DeathCounter")
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character:WaitForChild("Humanoid").Died:connect(function()
DeathCounterEvent:FireServer()
end)
end)
end)
Server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DeathCounterEvent = ReplicatedStorage:WaitForChild("DeathCounter")
function onDeathCounterEventFired(Player)
game.ReplicatedStorage.DataFile[Player.Name].TotalDeaths.Value = game.ReplicatedStorage.DataFile[Player.Name].TotalDeaths.Value + 1
end
DeathCounterEvent.OnServerEvent:connect(onDeathCounterEventFired)
Neither of them work, does anyone have any ideas as to why?
Thank you for your time also they dont error either, also Merry Christmas!

2 comments
Put the first script into the Server side, all delete the other scripts that deals with Death Counters.
Okay that worked thanks dude, if you want the rep go ahead and post an answer and ill accept. But untill then ill just say the problem is solved in the title.