So I'm trying to make my own custom cash shop. But when I click the button to buy it, it removes the money but the cash GUI stays the same and doesn't update.
Changes the text label to the correct amount of cash
game.Players.PlayerAdded:Connect(function(plr) wait(1) -- So the script can find the PlayerGui in the player. local PlayerGui = plr.PlayerGui while wait() do PlayerGui.YourCash.Frame.TextLabel.Text = "Your Cash: "..plr.leaderstats.Cash.Value -- Changes the TextLabel's text to the correct amount of cash. print(plr.leaderstats.Cash.Value) end end)
There is no output errors and I know this script works because there's a GUI that comes up which gives you money for playing the game and the GUI that shows your money updates with that. But for some reason not the thing you bought. The script above is in ServerScriptService and in a folder called "Leaderboard". The script is a global script. (It doesn't show others money just the players which is what I want.
Below is the script which buys the product.
local Button = script.Parent local Player = game.Players.LocalPlayer Button.MouseButton1Click:Connect(function() if Player.leaderstats.Cash.Value >= 100 then print("Greater than 100") Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value - 100 end end)
Again 0 output errors. This code is in a local script inside of the text button. I checked and it does decrease the IntValue named "Cash". But it wont update the GUI like it should.
I'm honestly puzzled as to what is going wrong. If you can help me, that would be appreciated.
Below are some pictures which might help you understand more.
Picture below located in Workspace. https://gyazo.com/75f96d7ff6544366e53f744e3c9974f4
https://gyazo.com/709339fa764099c61ba2c1c491d39ea0
https://gyazo.com/4c08e84298bce12483dc3b6855795bb6
Below is a little GIF for you to see.
https://gyazo.com/e811a32bd954099696580a8a7271fa73
Again if you are able to help me, that would be very appreciated. I've done the best I could setting up this question, if you need anything else please ask.