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

Gui works in studio mode, but not online?

Asked by
Relatch 550 Moderation Voter
10 years ago

This is a basic script that seems to work in studio mode, but not online.

local player = game.Players.LocalPlayer

player.leaderstats.Points.Changed:connect(function()
    script.Parent.Parent:TweenPosition(UDim2.new(0.4, 0, 0.2, 0), "Out", "In", 1.5, true)
    wait(5)
    script.Parent.Parent:TweenPosition(UDim2.new(0.4, 0, 1, 0), "Out", "Back", 1.5, true)
end)
1
Is this a Script or a LocalScript? BlueTaslem 18071 — 10y
0
Script, why? Relatch 550 — 10y

1 answer

Log in to vote
6
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

You can only access the LocalPlayer property from a LocalScript.

For Script objects, it will always be nil.

This is because it is not clear which player is "local" when a non-LocalScript is being run -- it's run by the server.


Use a LocalScript instead of a Script; or don't use the LocalPlayer as the way to reference the GUI objects (e.g., script.Parent.Parent.Label or the equivalent for your path)

0
Understood, good luck for 1,000! Relatch 550 — 10y
Ad

Answer this question