I have finally created a TextButton GUI on the edge of the screen (So happy about it too :P), and put in a script that would cause teleportation on click. However, it is not working.
Here is the code I am using.
bin = script.Parent function onClick() if Part.Parent:FindFirstChild("Torso") then Part.Parent.Torso.CFrame = CFrame.new(Vector3.new(84, 160, 12)) end end bin.MouseButton1Click:connect(onClick)
I suspect it has something to do with the variable or the function. If you could, may you put comment snippets in the code to show where you changed something?
Thank you in advance.
Edit: Also, where should I put the script? I have a ScreenGUI, which is a parent to TextButton, which the script is in. Is this correct?
You indeed didn't set what Part is. My guess is that part should be your character.
bin = script.Parent Part = game.Players.LocalPlayer.Character function onClick() if Part:FindFirstChild("Torso") then Part.Torso.CFrame = CFrame.new(Vector3.new(84, 160, 12)) end end bin.MouseButton1Click:connect(onClick)
You didnt set what part is (i mean, part is not a variable), so then the script breakes. Tip: let output open when you test something, there it will show the errors( the text thats on red).