I just made a simple and quick system right now and I’ll release my scripts on how I did it, here it is:
Make sure to add RemoteEvent inside of ReplicatedStorage you can change name if you want but make sure that you also do inside scripts.
Script in ServerScriptService:
local Event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent",4)
game:GetService('Players').PlayerAdded:Connect(function(player)
game:GetService("Players").CharacterAutoLoads = true
player.CharacterAdded:Connect(function(character)
game:GetService("Players").CharacterAutoLoads = false
character:WaitForChild("Humanoid").Died:Connect(function()
--Change here location to your dead screen frame or button as I did.
player.PlayerGui:FindFirstChild("DeadScreen"):FindFirstChild("TextButton").Visible = true
end)
end)
end)
Event.OnServerEvent:Connect(function(player)
player:LoadCharacter()
end)
LocalScript inside of a button for reset character:
local Event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent",4)
script.Parent.MouseButton1Down:Connect(function()
Event:FireServer()
end)
local Event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent",4)
No reason to have a WaitForChild().
There is no reason to have :FindFirstChild(). Just indexing it would be good, also Humanoid does load in time unless if you have a HUGE game. You are better of using :FindFirstChildWhichIsA.