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

How do I make it teleport the character when I click a gui button?

Asked by 6 years ago

It doesn't have an error in output- yet it doesn't teleport? Could you please help? Thanks!

brickposition = workspace.clothTeleP.Position

function telePart() if workspace:findFirstChild("Player") then
game.Workspace.Player.Torso.Position = Vector3.new(brickposition) end end

script.Parent.MouseButton1Up:connect(telePart)

0
Please use code block, thank you JellyYn 70 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Well, may I can help with this code.

local Position = game.Workspace.clothTeleP.Position
local Player = game.Players.LocalPlayer -- Incase that you're making this from a LocalScript* else, replace "LocalPlayer" with your username like: "game.Players.djunicorn205"
local Character = Player.Character or Player.CharacterAdded:Wait() -- Gets your character or waits until it spawns
local HumanoidRoot = Character:WaitForChild("HumanoidRootPart") -- The "HumanoidRootPart" works for both R6 and R15*
local Button = script.Parent

function telePart()
    HumanoidRoot.CFrame = CFrame.new(Position) -- If you set the torso's position via a Vector3, the character dies because it changes a single part's position while a CFrame changes the part's position and all the parts that are connected relatively
end

Button.MouseButton1Up:Connect(telePart)

In case that you don't understand this, watch this youtube tutorial:

https://www.youtube.com/watch?v=2BJz9qlYNIU

Resources:

http://wiki.roblox.com/index.php?title=API:Class/LocalScript http://wiki.roblox.com/index.php?title=API:Class/Humanoid http://wiki.roblox.com/index.php?title=CFrame

http://wiki.roblox.com/index.php?title=API:Vector3

Hope that helps.

-AlessandroG200(Sorry for any grammar mistakes.)

Ad
Log in to vote
0
Answered by 6 years ago

Try this

brickposition = workspace.clothTeleP.Position

function telePart() 
if workspace:findFirstChild("Player") then
game.Workspace.Player:MoveTo(Vector3.new(brickposition))
end
end

script.Parent.MouseButton1Up:connect(telePart)

Answer this question