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?

2 comments
you could use math.min to clamp it down on a certain value
coins.Value = math.min(coins.Value,MaxValue)