So, sorry.. I'm not too good at scripting... I made a GUI that teleports a player to somewhere when they click it and don't know why it doesn't work..
function clicked (click) local target = CFrame.new(189.87, 69.6, -216.3) player = click.Parent:FindFirstChild("Torso") player.CFrame = target end script.Parent.MouseButton1Click:connect(clicked)
AND, output said this when I clicked the GUI to test:
18:44:31.449 - Players.Player.PlayerGui.BattlefieldTeleportGUI.TextButton.:4: attempt to index local 'click' (a nil value) 18:44:31.451 - Stack Begin 18:44:31.453 - Script 'Players.Player.PlayerGui.BattlefieldTeleportGUI.TextButton.', Line 4 18:44:31.454 - Stack End
Don't do that use this:
plr = script.Parent(you need parents until the parent of startergui, the parent of startergui is the player)
the click is a parameter for mouse, not for the button, also try :WaitForChild i find it more affective
I'd recommend using :MoveTo() in this case, besides it's easier to understand if you aren't that good at scripting.
All you have to do its create a part and put it inside workspace in the position you want to teleport the character to.
function clicked (click) local player = game.Players.LocalPlayer -- make sure it's a LocalScript player.Character:MoveTo(Workspace.Part.Position) -- Move the Character to your part end script.Parent.MouseButton1Click:connect(clicked)
Hope this helped..