I’m having a minor problem with my code. I’m most likely overthinking it and may end up solving the problem myself. Since my project is a personal project, and I’d rather not leak my code - I’ll put it in a simplified way.
For my issue, I am using an integer variable for logging purposes. When the user clicks a button, the variable is supposed to go up by 1, but needs to reset to 0 after it hits 6. However, the variable doesn’t reset until it hits 7. Below is a simplified form of my code. There’s a lot of stuff here, and formatting may not be the greatest, so please try and look at it the best you can.
local button = script.Parent -- this is the button a user clicks.
local x = 0 -- the integer variable we're talking about here
local a = false -- assume this is true later in my example
local function changeLog()
if a == true then
x = x + 1
print(x)
end
if x == 1 then -- real code does more, but integer variable doesn't change. so, we'll just output the variable
print(x)
else if x == 2 then
print(x)
else if x == 3 then
print(x)
else if x == 4 then
print(x)
else if x == 5 then
print(x)
else if x == 6 then
print(x)
else if x >= 6 then
x = 0
print(x)
end
end
end
end
end
end
end
end
button.Activated:connect(changeLog)
Like I said, I may be overthinking it. It’s probably just a simple solution, where I say “else if x == 6 then do this” or something like that. Thanks for taking the time to read my post. Anything helps. 