This script is inside of a button that, when clicked, is supposed to lower your Money leaderstat, (it does this) raise a value, and make a GUI pop up on your screen for a short time. (it doesn't do any of this) Originally, the LocationsPercentage was to be raised by 0.05. I tried making it a non-decimal number to see if it would work then, and it did. Why doesn't arithmetic was decimals work? Even with the LocationsPercentage arithmetic working, the GUI doesn't pop up. Nor does it pop up if you don't have $10k. If you click it while your Money stat is under $10k, literally nothing happens. This is especially confusing because I have this script implemented in many other places around the game and it works fine there. What the heck? Edit: The script is a LocalScript, as are all of the scripts where this script works.
script.Parent.MouseButton1Click:Connect(function() local Money = game.Players.LocalPlayer.leaderstats.Money if Money.Value < 10000 then game.Players.LocalPlayer.PlayerGui.Folder.NotEnoughMoneyGui.Frame.Visible = true wait(2) game.Players.LocalPlayer.PlayerGui.Folder.NotEnoughMoneyGui.Frame.Visible = false elseif Money.Value >= 10000 then Money.Value = Money.Value - 10000 game.Players.LocalPlayer.LocationsPercentage.Value = game.Players.LocalPlayer.LocationsPercentage.Value + 0.05 game.Players.LocalPlayer.PlayerGui.Folder.SuccessfulPurchaseGui.Frame.Visible = true wait(2) game.Players.LocalPlayer.PlayerGui.Folder.SuccessfulPurchaseGui.Frame.Visible = false end end)
You should use variables it makes the code much easier to read.
-- script as a child of 'PlayerGui' local playerGui,player = script.Parent,script.Parent.Parent local money = player:WaitForChild("leaderstats").Money local declined = playerGui:WaitForChild("Folder").NotEnoughMoneyGui.Frame local success = playerGui.Folder.SuccessfulPurchaseGui.Frame local locationPercentage = player.LocationsPercentage local button = playerGui.Button button.MouseButton1Click:Connect(function() -- when it's easier to read, it's easier to fix. if money.Value < 10000 then declined.Visible = true wait(2) declined.Visible = false elseif money.Value >= 10000 then money.Value = money.Value - 10000 locationPercentage.Value = locationPercentage.Value + 0.05 success.Visible = true wait(2) success.Visible = false end end) -- use the 'print()' function to debug your script
Also, I don't know if this is a test but you should have FilteringEnabled set to true and you should be keeping your values server-sided and use remote events with values in your game like money especially, else your game will be hacked.
Filtering Enabled info: https://devforum.roblox.com/t/how-do-i-even-go-about-using-filtering-enabled/150072