CharacterAdded and Died doesn't work in LocalScript

So I want the player to become a zombie when they die but the problem is the localscript doesn’t do anything at all when the player dies.

player.CharacterAdded:Connect(function()
	player:WaitForChild("Humanoid").Died:Connect(function()
		print("LocalPlayer, “Has died!")
		if workspace.Main.Game.Value == true then
			workspace.ZombieDetect:FireServer()
			print("hi")
		end
	end)
end)

Because Humanoid isn’t in the Player instance. You are trying to get the Humanoid from the Player instance, get it from the character instead. .CharacterAdded event also returns the character:

player.CharacterAdded:Connect(function(Character)
	Character:WaitForChild("Humanoid").Died:Connect(function()
		print("LocalPlayer, “Has died!")
		if workspace.Main.Game.Value == true then
			workspace.ZombieDetect:FireServer()
			print("hi")
		end
	end)
end)
1 Like

You should also use a server script cause exploiters can manipulate local scripts and delete them as well.

1 Like

It still doesn’t do anything for some reason

uhh you can’t use FireServer in the server script, you can only use <RemoteEvent>:FireClient() and setup the function in order for the event to start in the client

I am using a localscript not a serverscript

1 Like

Nvm this works I just had a repeat wait thing preventing that to work

yes i was explaining why you were using a local script

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.