Teleporting script does not work

  1. What do you want to achieve? Keep it simple and clear!
    A door that makes it so that when the door handle is clicked it will teleport the player that clicked it.
  2. What is the issue? Include screenshots / videos if possible!
    It refuses to work
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I watched a few tutorials, no luck.

This is in a normal script, not local.

local Handle = script.Parent
local ClickD = Handle.ClickDetector
local Tele = Handle.Parent.Parent.Tele

function Teleport()
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.Tele.Position)
end

	ClickD.MouseClick:Connect(Teleport)

Tele is thing I want the player to teleport to, and handle is the thing they click, inside handle is a click detector and the script, and the handle is in a folder.

Alright so…

First, you cannot use Local Player inside of a regular script (Only works with Local Script).

Second, You could utilize instead a MoveTo() function to where it teleports the player to the position of a part.

ClickD.MouseClick:Connect(function(plr)
   plr.Character:MoveTo(game.Workspace.Tele.Position)
end)

You can read more about how this works here: What is the best way to move a character?

1 Like

Ok, good to know, i’ll test this out later but I have to go. I’ll let you know if that works, thanks!

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