I’m running the following code on RunService.Heartbeat;
function ParryLoop(step)
if count < limit and parried == false then
count = count + step
else
print("HCS_Client | Parry phase ended. PARRYLOOP")
connection:Disconnect()
end
end
Up until the print, everything works fine, however once I do reach the print, it will skips over the connection:Disconnect
and straight back to the print, as shown in this GIF of me using Step In & Step Out to go through line by line.
Without the break, it looks like this. (On contact with the Dummy, the player receives an event that changes parried
to true
.)
connection
is defined at the start of the script, just as local connection
without any value. I then have connection = RunService.Heartbeat:Connect(ParryLoop)
in a function to begin the Loop, which is supposed to end itself but obviously does not.
Putting another print after the Disconnect means that the script does actually go over the line, but the Disconnect still doesn’t fire. I use the exact same method elsewhere in the same script and it works fine in every other case.
This issue does not happen every time on contact with the Dummy, but completely breaks the script when it does.
I have absolutely no clue what could be causing this, I’ve asked around in a few Discord servers but no solution yet