Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a player teleport to a different position?

Let me explain, i want it so that when a player clicks a part they will be teleported to a different position and i dont know how to do it. (I know most basic to medium level code just not advanced or Cframe so i don't know how to do this) I don't know if it should be a local script or anything like that.. So plz help

Anytime i search it it just shows up with how to teleport players to a different game rather than different position which is why im asking here

2 answers

✓ Accepted answer

This script should work fine. Make sure there is a click detector in the brick you want to be able to be clicked on first, as well as to make sure the script's parent is the brick you want to be able to be clicked

function onClicked(player)
	player.Character.HumanoidRootPart.CFrame = CFrame.new(0,0,0) -- replace this with the location you want
end

  script.Parent.ClickDetector.MouseClick:connect(onClicked)

This method of teleporting players uses CFrame, but it's rather easy and simple. It uses SetPrimaryPartCFrame()

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()


-- Example of how to use SetPrimaryPartCFrame(). This will not work by just copying this script, you'll have to do it yourself!

ClickDetector.MouseClick:Connect(function()
	char:SetPrimaryPartCFrame(workspace.Part.CFrame) 
	-- change workspace.Part to any BasePart in workspace!
end)

Hope this helps! Be sure to accept this answer if this helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.