Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

on screen gui button that teleports player to a part?

Asked by
steev 0
10 years ago

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

Log in to vote
0
Answered by
nate890 495 Moderation Voter
10 years ago

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)

Ad

Answer this question