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

Gui works in studio mode, but not online?

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)

2 comments

1

Is this a Script or a LocalScript?

0

Script, why?

1 answer

✓ Accepted answer

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)

1 comment

0

Understood, good luck for 1,000!

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