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

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

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)

1 comment

0

Please use code block, thank you

2 answers

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.)

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)

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