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

Gui not getting updated?

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.

5 comments

0

I believe "Currency" is supposed to be a child of "leaderstats". Try to fix up your cash path.

0

No. It's located within the player. Not leaderstats. If that was a case it would error finding it.

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)

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?

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?

1 answer

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.

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