I have a teleporter that I'm trying to make that sends you to a shop in my game. The problem is the brick I'm trying to make it teleport you to also sends you back. I've added a debounce to make sure players can't infinity get teleported between the two bricks. I've tried this script and it doesn't teleport you like I'm trying to make it do and there's error in output. If anyone has a clue as to why this doesn't work, that would be awesome.
local teleportbrick1 = workspace:WaitForChild("TeleportBrick1") local teleportbrick2 = workspace:WaitForChild("TeleportBrick2") local waittime = 3 local touched = false local function teleport(position) return function(hit) if not touched then touched = true local character = game.Players:GetPlayerFromCharacter(hit.Parent).Character local head = character and character:FindFirstChild("Head") if head then head.CFrame = position end wait(waittime) touched = false end end end teleportbrick1.Touched:connect(teleport(CFrame.new(61.5, 70.7, -123.5))) teleportbrick1.Touched:connect(teleport(CFrame.new(-69.5, 15.6, -44.5)))
Hi.
:MoveTo() is meant to walk the player to that location.
If you're looking to teleport you should change the CFrame to the torso to the new position.
A small example:
part = script.Parent tp = game.Workspace.tp2 part.Touched:connect(function(hit) if hit.Parent.Humanoid then hit.Parent.Torso.CFrame = CFrame.new(tp.CFrame.X, tp.CFrame.Y, tp.CFrame.Z) end end)
The above is an example that should work.
-- Untested, try this script.. local PartToTouch = script.Parent -- if you touch that certain part PartToTouch.Touched:connect(function() local GoTo = game.worskpace.TeleportPart -- First off all change that to the part u wanna teleport to local char = game:GetService("Players").LocalPlayer:GetCharacter() -- get the players character local torso = char.Torso -- get the players torso torso.Position = Goto.Position + Vector3.new(0,10,0) end)
I guess this will work