I have tried different ways. This is the most recent:
local player = game.Players.LocalPlayer local endingPos = Vector3.new(-17.93, .5, 360.89) script.Parent.MouseButton1Click:Connect(function(teleport) local inJobspot = false function teleport(par1) if not inJobspot then par1.Character:MoveTo(endingPos) inJobspot = true end end end)
This is actually a pretty simple answer. I'm not sure if yours works, because I did not check but this one works, and I'm sure it will for you too. But make sure that this code is in a LOCAL SCRIPT.
local plr = game.Players.LocalPlayer --// Gets the local player. local char = plr.Character or workspace.ChildAdded:Wait() --// Gets the player's character. local endingpos = Vector3.new(0,15,0) --// The position you want. function teleport() --// Making a function. char:MoveTo(endingpos) --// Moving the player to the ending position end script.Parent.MouseButton1Click:Connect(teleport) --// Calling the teleport function by clicking script.Parent
Try the following. I haven't yet tried it.
local player = game.Workspace.Player -- This is a current player, so I assume this should be put into a localscript local endPos = Vector3.new(-17.93, .5, 360.89) -- The end location function teleport() -- Define function player.HumanoidRootPart.CFrame = endPos end script.Parent.MouseButton1Click:Connect(teleport())