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

I can't make a script that only teleports alive players, how should i fix it?

I tried to make a script that teleports player if player is alive, but it doesn't teleport at all.

script.Parent.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	
	if humanoid then
		if hit.Health > 0 == true then
			hit.Parent:MoveTo(game.Workspace.Spawn1.Position)
		end
	end
end)

2 answers

Remember that hit is the Part that touched the other part. You're trying to do hit.Health. You need to do humanoid.Health. Small mistake!

No need to do == true, just do:

if hit.Health > 0 then

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