I am trying to make a Hunger Thirst System and i cannot figure out how to limit the value on 100. so that a player cannot be 115 full of water.
This is the code that i have:
local Player = game.Players.LocalPlayer
local leaderboard = Player:WaitForChild("Leaderboard")
local Tool = script.Parent
Tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
leaderboard.Thirst.Value = leaderboard.Thirst.value + 15
Tool:Destroy()
end)
end)

1 comment
math.clamp could also work. It takes 3 parameters, the number to clamp, the minimum, the maximum. If the number is greater than the maximum it'll return the maximum. If the number is lower than the minimum it'll return the minimum. Otherwise, it'll return the same number.