Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Teleport script spams console and takes forever to teleport?

Asked by 9 years ago

So i built a teleport script which is in a localscript which is in a GUI at the moment. However to takes forever to be teleported. My console gives me "bad request" errors and they never end until I am teleported. As well as the fact that sometimes the game I want to be teleported to crashed. I wanted to know if there was a better way or more stable way to use this teleport script. I sat once for 3 minutes till the script finally teleported me. Exuse my lack of teleporting players to different games knowledge I just started this.

player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:connect(function()
    game:GetService("TeleportService"):Teleport(334747890, player)
end)

1 answer

Log in to vote
1
Answered by 9 years ago

I think you defined player wrong. The easiest way I find to define the player is instead of local player, I use

player = script.Parent.Parent.Parent.Parent.Parent

So, I would try to use

player = script.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Down:connect(function()
    game:GetService("TeleportService"):Teleport(334747890, player)
end)

And the reason for your spam was due to you defining player wrong. If you use local player, the game must search for it, taking longer. Meaning you should always use the defining method I used.

player = script.Parent.Parent.Parent.Parent.Parent

0
The script should not be having to look for LocalPlayer, it's a property for Players that gets set for each client. I do not see why the user's script was not working, however you should not have to use multiple parents just to find the player in a local script. M39a9am3R 3210 — 9y
0
Sorry for doing it the way I was taught.. TheHospitalDev 1134 — 9y
1
You were poorly taught. Teaching other people hacky and horrid ways rather than making a suitable solution is wrong. The only way I think of possibly fixing it is adding a "local" before the variable to push it to the top of the stack. DevChris 235 — 9y
Ad

Answer this question