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

Why will this teleport script not work?

Asked by 9 years ago

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.

0
Is it in a local script? Because LocalPlayer only works in LocalScripts. KennySfromTitan 106 — 9y
0
No it is not. Could you change this to work in the script parent. Conmmander 479 — 9y

2 answers

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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.

Ad
Log in to vote
0
Answered by 9 years ago
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.

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 CoffeeMesh 5 — 9y

Answer this question