Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why will this teleport script not work?

I built a teleport script but I get an error saying player not found when playing In game. This works in the workspace however.

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

I get 0 player console errors.

2 comments

0

Is it in a local script? Because LocalPlayer only works in LocalScripts.

0

No it is not. Could you change this to work in the script parent.

2 answers

✓ Accepted answer

Assuming this is in a GUI, you simply need to change this Script into a LocalScript for it to work, as LocalScripts will run inside a Player's PlayerGui.

player = script.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Down:connect(function()

    game:GetService("TeleportService"):Teleport(334747890, player)
end)

Let me know if this worked? Ty.

1 comment

0

And i only made it this way because i saw that you commented saying you wanted this to be able to work with a script instead of a localscript

This discussion is preserved as it was. New answers, comments, and votes are closed.