Teleportation help script

it has the same error. I do not understand why

1 Like

here new one

local Touched = false
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		Touched = true
		task.wait(2)
		hit.Parent.HumanoidRootPart.CFrame = CFrame.new(46, 60.25, -110.669)
		Touched = false
	end
end)
1 Like

the teleporter still sends you to the other part even if you step off.

Alright so, you re trying to add a delay.

Here you go.

script.Parent.Touched:Connect(function(hit) -- Detect if the player is touching it
    if hit.Parent:FindFirstChild("Humanoid")  then -- if the "Hit" is the Humanoid
        delay(2, function() -- Delay to check if the player is still touching it
		   hit.Parent:MoveTo(Vector3.new(46, 60.25, -110.669)) -- Change the CFrame of the Character
	    end)
    end
end)
1 Like

Can u explain what u really want

It has the same error. if you step off, it still teleports you

Example: You step on part. You must stay in the part for two seconds, once you have stayed there for two seconds you then get teleported to the new location.

Try this,

script.Parent.Touched:Connect(function(hit) -- Detect if the player is touching it
    if hit.Parent:FindFirstChild("Humanoid")  then -- if the "Hit" is the Humanoid
        delay(2, function() -- Delay to check if the player is still touching it
		   hit.Parent:MoveTo(Vector3.new(46, 60.25, -110.669)) -- Change the CFrame of the Character
	    end)
    end
end)

if it is not working then try this one,

script.Parent.Touched:Connect(function(hit) -- Detect if the player is touching it
    if hit.Parent:FindFirstChild("Humanoid")  then -- if the "Hit" is the Humanoid
        delay(2, function() -- Delay to check if the player is still touching it
            if hit.Parent:FindFirstChild("Humanoid")  then -- if the "Hit" is the Humanoid
		       hit.Parent:MoveTo(Vector3.new(46, 60.25, -110.669)) -- Change the CFrame of the Character
            end
	    end)
    end
end)

it has the same error, it still doesn’t work as intended.

New One

local Touched = false
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		Touched = true
		if script.Parent.TouchEnded then
			return Touched
		end
		task.wait(2)
		hit.Parent.HumanoidRootPart.Position = Vector3.new(46, 60.25, -110.669)
		Touched = false
	end
end)

Ive already responded on ur old page

its better to add a teleport part (the destination part) instead of presetting a CFrame
create a part, and set it as the “DestinationPart”

local Touched = false
local destpart = workspace.nameofdestinationpart

script.Parent.Touched:Connect(function(hit)
 if hit.Parent:FindFirstChild("Humanoid") and not Touched then
  touched = true
  task.wait(2) 
  hit.Parent.HumanoidRootPart.CFrame = destpart.CFrame
  touched = false
 end
end)

plus i found a lot of unicode

It has the same error I started off with.(“Humanoid”) and not Touched then
touched

do it again, i found Unicode in the given script
remember to add a part that is marked as the target position

It still doesn’t work. I don’t understand.

the touch = on the last few lines is yellow

Are u using a local script in workspace?
If Yes, Local Scripts don’t work in workspace, That should be why it is not working.

If No, Use

local part = script.Parent
local Debounce = false

part.Touched:Connect(function(hit)
	local Character = hit.Parent
	local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
	if not Player then return end
	if not Debounce then
		Debounce = true
		Character:PivotTo(CFrame.new(46, 60.25, -110.669))
		task.wait(2)
		Debounce = false
	end
end)

Helloo, :wave:

I’ve recreated the code and tested it, it should work now :smile:

local touched = false

script.Parent.Touched:Connect(function(hit) -- Detect if the player is touching it
	if hit.Parent:FindFirstChild("Humanoid")  then -- if the "Hit" is the Humanoid
		touched = true -- set bool to true
		task.delay(2, function() -- Delay to check if the player is still touching it
			if touched == true then -- if bool is set to true
				hit.Parent:MoveTo(Vector3.new(46, 60.25, -110.669)) -- Change the CFrame of the Character
			end	
		end)	
	end	
end)

script.Parent.TouchEnded:Connect(function(hit) -- Detect if the player is NOT touching it
	if hit.Parent:FindFirstChild("Humanoid") then -- if the "Hit" is the Humanoid
		touched = false -- set bool to false
	end
end)

(i replied to the wrong feedback lol)
i would appreciate a checkmark :white_check_mark:

1 Like

Thank you bro. This is fantastic!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.