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

on screen gui button that teleports player to a part?

How would you make an on screen gui that teleports a player to a part (brick)

For example: The player enters the game and a on screen gui button is shown. The player clicks the gui button and is teleported on to a brick (part)

how would you do this in Lua? and also i know how to rename the brick that is the teleporter

And also im not saying any random part just one renamed part itself.

1 answer

✓ Accepted answer

To move a player we must use the MoveTo method or change the CFrame of the player's torso.

local myGui = script.Parent
local part = game.Workspace.Brick

local player = game.Players.LocalPlayer

myGui.MouseButton1Down:connect(function()
	if player.Character then
		player.Character:MoveTo(part.Position + Vector3.new(0, 5, 0)) -- moves the character about 5 studs above parts position (this is so the character doesn't fall through the ground
	end
	myGui:Destroy() -- removes the GUI so it cannot be used to teleport again.
end)

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