ive made a hunger script and whenever i eat something the value goes over 100 and i want the cap to be 100
COMMUNITY QUESTION
how does one set a limit on int values?
2 answers
You can do this easily with a simple script that goes something like this:
local hunger = script.Parent --change 'script.Parent' to your hunger value
--if for some reason their hunger is above 100 when they join
if hunger.Value > 100 then --if the value is over 100 then
hunger.Value = 100 --changes the value to 100
end
--fires when the player's hunger is changed and checks to see if its above 100
hunger.Changed:Connect(function()
if hunger.Value > 100 then --if the value is over 100 then
hunger.Value = 100 --changes the value to 100
end
end)
local intValue = YourIntValue -- Put the path to your intValue
If intValue.Value > 100 then
intValue.Value = 100
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
