Discord
Login
Community
DARK THEME

how do you make it so it only updates a variable once in an if loop

i have started on the inventorie but the stats go up infinently on equiping an item eg:

if hat = "helmet of bob" then def += 4 end

please help if you have time to

You are adding 4 to def every frame it recognizes that you are wearing the helmet. It can be resolved by resetting the stats to 0 at the beginning of the loop, then adding on the correct amount.

update = function()
  local pass = false
  for i = 1 to 100 by 1
    if not pass and hat == "helmet of bob" then 
      def += 4 
      pass = true
    end
  end
end

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community