Need help with a teleport script

local s = script.Parent
local Debounce = false

s.Touched:Connect(function(hit)
	
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	
	if humanoid ~= nil and Debounce == false then
		
		Debounce = true
		
		coroutine.wrap(function()
			Debounce = false
			task.wait(.1)
			
			hit.Parent.LowerTorso.CFrame = game.Workspace.SpawnLocation.CFrame	
			
		end)()
		
	end
end)

When i touch the teleport part it teleports me to it more than once and glitches

1 Like

i recommend using HumanoidRootPart instead if LowerTorso,
and also, why you using Debounce?

2 Likes

When i use Humanoid root part it teleports me under the block

try to add this “hit.Parent.HumanoidRootPart…CFrame = game.Workspace.SpawnLocation.CFrame+ Vector3.new(0.10.0)”

Yes but why do this when lowertorso works fine?

oh, i read wrong, so, you don’t need to use debounce and corountine function and task

local s = script.Parent
local Debounce = false

s.Touched:Connect(function(hit)
	
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	
	if humanoid ~= nil then
		
		hit.Parent.HumanoidRootPart.CFrame = game.Workspace.SpawnLocation.CFrame	

	end
end)

The problem with this is its registering my legs as two seperate touches so teleports me twice

try this:

local s = script.Parent

s.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
hit.Parent.LowerTorso.CFrame = game.Workspace.SpawnLocation.CFrame
end)
end
end)

This is just the same script without the nil

oh, you remove corountine.warp() sec

which script do you use?
localScript or Script

i wrote this script, for me it works fine

local part = script.Parent

part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
hit.Parent.HumanoidRootPart.CFrame = workspace.SpawnLocation.CFrame + Vector3.new(0,10,0)
end
end)

The script is fine, it just runs twice I need to find a way to stop this.

local part = script.Parent
local deb = false

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild(“Humanoid”) and not deb then
        deb = true
        hit.Parent.HumanoidRootPart.CFrame = workspace.SpawnLocation.CFrame + Vector3.new(0,10,0)
        wait(0.2)
        deb = false
    end
end)

Now it won’t run twice. Just add a debounce to stop that.

1 Like

Here is example teleport to spawn

local part = script.Parent
local Debounce = true

part.Touched:Connect(function(hit)
	if Debounce then
		if hit.Parent:FindFirstChild("Humanoid") then
			Debounce = false
			hit.Parent.HumanoidRootPart.CFrame = workspace.SpawnLocation.CFrame + Vector3.new(0,5,0)
			wait(0.1)
			Debounce = true
		end
	end
end)

If can make teleport pad for obby.
example teleport to tag on group

local part = script.Parent
local tele = script.Parent.Parent.Tag
local Debounce = true

part.Touched:Connect(function(hit)
	if Debounce then
		if hit.Parent:FindFirstChild("Humanoid") then
			Debounce = false
			hit.Parent.HumanoidRootPart.CFrame = tele.CFrame + Vector3.new(0,5,0)
			wait(0.1)
			Debounce = true
		end
	end
end)
1 Like