So, I inserted this code (code will be pasted at the bottom) into a local script and placed that script in StarterPlayerScripts. I have no idea why it isn't working. This code is supposed to reset your cash to 0 if you have 100 or more.
local cash = script.Parent.Parent.leaderstats.Cash.Value local limit = 100 -- Change this to whatever you want the max value to be. cash.Changed:connect(function(Value) print'cash' if cash >= limit then -- If the cash if equal to or greater than 5, then set it to 0. cash = 0 end end)
Try this.
local player = game.Players.LocalPlayer local character = player.CharacterAdded:wait() -- Wait for Player local p = Instance.new("NumberValue") p.Name = "cash" p.Parent = player local cash = player:WaitForChild("cash") local limit = 5 -- Change this to whatever you want the max value to be. cash.Changed:connect(function(NewValue) print(cash.Value) if cash.Value >= limit then -- If the cash if equal to or greater than 5, then set it to 0. cash.Value = 0 end end)