I am having trouble updating a text label every time a player earns money. It updates just fine on the scoreboard gui but I only want each player to see their respective scores when they open the menu (a text label). I have been able to create a text label that becomes visible and invisible on text button press but that's as far as I have gotten. I am unsure of where to go from here.
How to update a textlabel to show player score/money?
2 answers
You can use an Event of an IntValue ".Changed"
Questions:
What is it and when will it be fired?
The Changed event fires whenever the IntValue.Value of the IntValue is changed. It will run with the new value being stored in the argument object, This event, like other changed events, can be used to track when an IntValue changes and to track the different values that it may change to. For instance, this may be useful in games that rely on IntValues to track game states and values
local Money = ---- Player's Money ( The IntValue Object)
local TextLable = --- The Text Label you wanna change
Money.Changed:Connect(function(TheNewMoneyValue)
TextLable.Text = TheNewMoneyValue
end)
For more info: https://developer.roblox.com/en-us/api-reference/event/IntValue/Changed
If you want the TextLabel to update every time you earn money, here is the script: Remember to put this in a Local Script inside of the TextLabel!!!
while wait() do -- Every few seconds, do
local player = game.Players.LocalPlayer -- Find Player
script.Parent.Text = "Swipes:".. player:WaitForChild("leaderstats"):FindFirstChild("Swipes").Value -- Text Label's text will be this
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
