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

Remote Event wont work after humanoid dies?

When a player touches a part it takes damage, but when the player dies then respawns and touches the same part the player isn't taking damage.

LocalScript inside StarterPlayerScripts:

local player = game.Players.LocalPlayer local playername = player.Name local humanoid = game.Workspace:WaitForChild(playername) local realhumanoid = humanoid.Humanoid

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(player, hit) print("ok,ok") realhumanoid:TakeDamage(10) end)

Script in Part in Workspace:

script.Parent.Touched:Connect(function(hit) print(hit) local realplayer = hit.Parent.Name local realplayer2 = game.Players:FindFirstChild(realplayer) if hit.Parent:FindFirstChild("Humanoid")then print("ok") game.ReplicatedStorage.RemoteEvent:FireClient(realplayer2, hit) end end)

1 comment

0

You should not deal damage locally. You should be dealing it from the server.

1 answer

✓ Accepted answer

Heres a quick script i put together it should do what you want.

script.Parent.Touched:connect(function(touched)
	local humanoid = touched.Parent:FindFirstChild("Humanoid")
	if humanoid ~= nil then 
		--humanoid.Health = 0 -- player takes 10 damage / doesnt work if they have force field
		humanoid.Health = humanoid.Health - 10 -- player takes 10 damage / works if they have force field
	end
end)

i couldn't fully understand what you meant but hopefully this does what you need! What it should look in the explorer

1 comment

1

Thank you

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