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..
1 | function clicked (click) |
2 | local target = CFrame.new( 189.87 , 69.6 , - 216.3 ) |
3 | player = click.Parent:FindFirstChild( "Torso" ) |
4 | player.CFrame = target |
5 | end |
6 |
7 | script.Parent.MouseButton 1 Click: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.
1 | function clicked (click) |
2 | local player = game.Players.LocalPlayer -- make sure it's a LocalScript |
3 | player.Character:MoveTo(Workspace.Part.Position) -- Move the Character to your part |
4 | end |
5 |
6 | script.Parent.MouseButton 1 Click:connect(clicked) |
Hope this helped..