So i want to create a surface gui with a textbutton inside that when a player press it he got teleported to a coordinate The problem is that i found this script :
-- SurfaceGUI script, made by Jaitix!
--Put this in StarterGui, ALWAYS!
TeleportBack = game.Workspace.BackWall.Back.Frame.TeleportBack
-- Identifies TextButton
local player = game.Players.LocalPlayer
TeleportBack.MouseButton1Click:connect(function()
--if TextButton is Clicked, then
if player.Character and player.Character:FindFirstChild("Torso") then
-- if player and the character, and if it finds the torso
-- of the character
player.Character.Torso.CFrame = CFrame.new(29.184, 24, 35.262)
-- Teleports the player's torso to a new CFrame
-- Teleporting the torso makes it so the whole player
-- teleports to the CFrame coordinates
end
end)
This script is a LocalScript inside the StarterGui it work well in studio but in game it doesnt work and i got 0 error so i dont know what is the problem here so if you know help me ;)
