Hello. I'm trying to make a feature for my FPS Game for when you die you respawn. I'm making this because i have CharacterAutoLoads off. But for some reason when they die they dont respawn. I tested this with the print thing but its not running. Anyone know the fix for this? Thanks
Code: (Local Script in StarterPlayerScripts)
local charload = game.ReplicatedStorage:WaitForChild("CharLoad") game:GetService('Players').PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() charload:FireServer() end) end) end)
The problem is that you didn't specify the player when you were firing the server. But I think there is another easier way to do this.
Do what @OwoShiba said but not exactly... Instead of using a local script, use a server script and place it in the ServerScriptService. The only thing you should really change is the event parts because they are not needed. Like this:
game:GetService('Players').PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() -- code here :D end) end) end)
Np :)