Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

No Events firing on death of player?

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)

8 comments

0

whats the other script?

0

what other script? Do you mean the remote event script?

0

You can use the exact same script on server side, you don't need to detect it with a localscript.

0

@OwoShiba that's genius

0

@OwoShiba Oh. I didnt know that.

0

@OwoShiba wait that wouldnt work. because you can only do fireserver on the client.

0

Then don't FireServer. Use a bindable or do whatever you were supposed to do in this script.

0

wait i have another genius idea

1 answer

✓ Accepted answer

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 :)

2 comments

0

You don't have to pass the player as an argument when doing :FireServer. By default, the first argument is always the player that fired it.

0

ok

This discussion is preserved as it was. New answers, comments, and votes are closed.