✓ Accepted answer
GENERAL ISSUES
Use :GetService() to retrieve the Players Service
ISSUES
connect is deprecated in favor of Connect
REVISED SERVER SCRIPT
local DiedEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local Death = false
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:Connect(function()
print(Death)
if Death == false then
Death = true
DiedEvent:FireClient(player, Death)
end
end)
end)
end)
Keep in mind that I had to add a local variable for Death and DiedEvent without knowing where they were / their names, as well as a PlayerAdded / CharacterAdded Event.
I will also note that this function will only run once based on how it is written. If you want it to occur every time the player dies, simply remove the if-then statement.
local DiedEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local Death = false
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:Connect(function()
Death = true
print(Death)
DiedEvent:FireClient(player, Death)
Death = false
end)
end)
end)
If there are any other issues, you will have to release more of the code you are using since there are relatively few problems with what has been provided.
2 comments
I think whats happening here is the script reseting itself if its in StarterCharacterScripts, i don't really get what you mean tho
the script is in ServerScriptService, and everytime the character presumably kills himself the death screen only works every other time @Igoralexeymarengobr