Does anyone know how to set a max value for an intvalue? Because when I tried my script, it didn’t work here’s what I had, and I the folder is leaderstats and the coins are coins, VSpace is the max value
plr.leaderstats.coins.Changed:Connect(function() local max = VSpace.Value if coins.Value > max then coins.Value = max end end)
That’s what I had but whenever I collect a coin, it automatically sets the coins value to the max how do I fix this?
So would this be right theking28989987?
plr.leaderstats,coins.Changed:Connect(function() local max = VSpace.Value if coins.Value > max then coins.Value = math.min(coins.Value,max)
Is that right?
plr.leaderstats.coins.Changed:Connect(function() local max = VSpace.Value if coins.Value >= max+1 then coins.Value = max end end)