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)
You need to check if the value is smaller then 100 before adding this thirst value.
local Player = game.Players.LocalPlayer local leaderboard = Player:WaitForChild("Leaderboard") local Tool = script.Parent Tool.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() if leaderboard.Thirst.Value < 100 then -- Checking if the value is smaller then 100 leaderboard.Thirst.Value = leaderboard.Thirst.value + 15 Tool:Destroy() end end) end)
This code should work fine.