This is in a SurfaceGUI connected to a button.
Why isn't this working? Please answer this asap!
torso = script.Parent.Parent.Parent.Parent.Character.Torso function onClicked(GUI) torso.CFrame = CFrame.new(Vector3.new(-432, 2.2, 64)) end script.Parent.MouseButton1Click:connect(onClicked)
Best regards, Nathan.
~ Lava, from freedom comes elegance. ~
EDIT: I see what happened now that you gave me the Output error, but where do you EXACTLY have that SurfaceGui?... oh well, listen,
The script is trying to find an object inside Workspace called "Character", Which does not exist.
You can't just get the player like that.
This has already been asked a few times, Question 1 Question 2 Question 3
All the answerers said, it's impossible to get a player who clicked in a SurfaceGui.
There are two alternatives. Both alternatives don't use the SurfaceGui, it would only be for decoration, lol.
Option 1
You will have to add a LocalScript inside StarterGui or StarterPack and just add a simple part with a SurfaceGui Button in Workspace and add a StringValue inside the Button to store the player's name to later find the player with the correct name in playerservice, to later teleport the player it would be really complicated for you, and it's not really efficient.
Option 2
This is the easiest, and the most efficient, Store a ClickDetector inside a Part, so you can be able to click it, and get teleported thanks to the "player" argument it has included by default, compared to the .MouseButton1Down Event which does not have any.
--Inside ClickDetector local ClickDetect=script.Parent ClickDetect.MouseClick:connect(function(player) -- Player argument. if player.Character then local char=player.Character --Check for Character if char:FindFirstChild("Torso")==nil then return end --Check for Character's Torso local torso=char.Torso torso.CFrame=CFrame.new(0,0,0) end end) --Not guaranteed to work since I'm not in ROBLOX Studio right now.