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

How do I use a SurfaceGui to teleport a player to a specified location?

Asked by 7 years ago

The SurfaceGui is located in a Part of a Group, and inside the SurfaceGui is a TextButton that has a LocalScript. The LocalScript is supposed to teleport the player clicking the TextButton to a specified location, but I don't know how to make the LocalScript do that in my code .

local p = game.Players.LocalPlayer
local body = p.Character.HumanoidRootPart --HumanoidRootPart is used to make the game compatible with R15

function onClicked(GUI)
      body.CFrame = CFrame.new(Vector3.new( -281, 60.2, 238 ))
end

script.Parent.MouseButton1Click:connect(onClicked)
0
i dont think you can do it with HumanoidRootPart, i tried it in studio, the camera is moving and my character is doing the walking animation RobloxianDestory 262 — 7y
0
script i used: game.Workspace.Player1.HumanoidRootPart.Position = Vector3.new(0,0,0,0) RobloxianDestory 262 — 7y
0
oh my bad it does work with CFrame: game.Workspace.Player1.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(0,0,0,0)) RobloxianDestory 262 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

move the SurfaceGui to StarterGui and change the Localscript to this V

local p = game.Players.LocalPlayer
local player = game.Players:FindFirstChild(p.Name)
script.Parent.Parent.Parent.Adornee = game.Workspace(CHANGE THIS)
local body = p.Character.HumanoidRootPart --HumanoidRootPart is used to make the game compatible with R15

script.Parent.MouseButton1Click:connect(function()  

      body.CFrame = CFrame.new(Vector3.new( -281, 60.2, 238 ))
end)

line 3 will make it visible on the part when they join and it will get the name of the player since the surfacegui is in their playerGui, it's easily to find their name

dont forget to change the part on Line 3

0
or it might work if you add in line 2 without changing the location of the gui, if not try this, it works tested RobloxianDestory 262 — 7y
Ad

Answer this question