Heres the script:
local Teleport = "Tele4" function Touch(hit) if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true local Pos = script.Parent.Parent:findFirstChild(Teleport) hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end script.Parent.Touched:connect(Touch)
What I'm trying to do is make it if the players health is 0 (dead) then this script will not teleport them anywhere. Can someone help me with this?
Since Touched event provides you with the object that touched it, you can check if the parent of that part contains a Humanoid. You should always perform this check when you only want players to touch something. From there you can check the Health property of the humanoid is greater than 0.
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then --We got a player that touched local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid.Health > 0 then --Rest of your code goes here else --If the player is dead then don't do anything return end end end)