Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to prevent this from breaking?[Closed]

Asked by
tanzane 100
10 years ago
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

Log in to vote
3
Answered by 10 years ago

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

Ad

Answer this question