So I have this for loop, and regardless of when I make sure that “blockstopped = true” is called, it still continues to go through the countdown?
Is this another dumb error, or what?
function blockuse()
script.Parent.RemoteEvent:FireServer("BLOCKING")
blockanim:Play()
canattack.Value = false
for i = blocktime, 0, -1 do
wait(1)
print(i)
if blockstopped == true then
break
end
if i == 0 then
isblockcooldown = true
blockstop()
blockingcooldown()
break
end
end
end
We will need more information, could you post where you change blockstopped to true? Adding --!strict to the top of your script can help catch this bug if it is a simple misspelling issue.
I see a couple of problems. Nowhere in your function do I see where blocktime has been defined. What is the value that it starts with? And you don’t need the break with the if i == 0 then block because since 0 will be the last value that i takes before the loop exits, the code is redundant.
This is what’s known as a directive. It’s not interpreted as code by the compiler, but it gives instructions to the compiler. Similar to #pragma in gcc/clang-llvm.
This ended up being a problem with the wait times, the normal 30 frame period that wait() gives you wasn’t enough to register. Putting a simple 1 second interval into the wait parameters fixed it. Thanks for the help though you guys!
Well, LUA is a new language for me. With that being said, I’ve been using C/C++ and similar languages for something like 25+ years. I find that LUA is…limiting. One glaring omission is the lack of a switch statement.