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

How to prevent this from breaking?[Closed]

function Teleporter(hit)
if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
	hit.Parent:MoveTo(game.Workspace.SpawnLocation2.Position + Vector3.new(0,5,0))
	
	end
end

script.Parent.Touched:connect(Teleporter)

This script works and all, but I was testing my Obby and well When I died, my body landed on the teleporter. And I got a error. So is there a way for the button not to run when you touch it with 0 health?

1 answer

✓ Accepted answer

Yeah, In your if statement add a and hit.Parent.Humanoid.Health > 0 then

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