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

Gui not getting updated?

Asked by
lomo0987 250 Moderation Voter
10 years ago
repeat wait() until game.Players.LocalPlayer
local user = game.Players.LocalPlayer
local cash = user:FindFirstChild("Currency")
local gui = script.Parent
print("Points has started!")

game.Players.PlayerAdded:connect(function(iffy)
    gui.Text = "Points:"..cash.Value
    print("Joined and updated points")
        cash.Changed:connect(function(cotton)
        gui.Text = "Points:"..cash.Value
        print("updated")
    end)
end)

It will only do the first print 'Points has started!' and that's it. It doesn't change the Text at all or even give me an error.

0
I believe "Currency" is supposed to be a child of "leaderstats". Try to fix up your cash path. Shawnyg 4330 — 10y
0
No. It's located within the player. Not leaderstats. If that was a case it would error finding it. lomo0987 250 — 10y
0
Well, to find an error I would suggest clicking "Play" as if playing a normal game, Press F9 and see why the line errors. (Go to Server Console) Shawnyg 4330 — 10y
0
Do you not read what i typed? Why don't you read what i said under the script itself? You aren't giving me any information i can use. Really now, you are going to vote down because you didn't read what I typed? lomo0987 250 — 10y
0
Have you been trying with more than one player? Is cash actually being changed? Is it possible to access the PlayerAdded event from a local script? GoldenPhysics 474 — 10y

1 answer

Log in to vote
2
Answered by
User#2 0
10 years ago

This is a problem many people seem to have, so no worries.

What's happening is ( presuming this script is a local script located in StarterGui ) that objects are copied from the StarterGui when the player spawns, which is after they join.

Your script would run the function in the PlayerAdded connection line if PlayerAdded fired on the client (it doesn't). That's not what you want! What you want is to run the code when the local player is present.

The best way to fix this would be to remove the 7th and 14th (in this case) lines. This will let the code inside of that event run as the script runs, and you'd be fine as the player already exists. Mentioning that, you could also lose the first line (again, in this case) because the player is already present when this runs.

Ad

Answer this question