Make the enemy unable to attack the player for a specific time

I have a melee combo chain system and I want to make the enemy unable to attack me whenever I register a hit, after a specific time the enemy is abled to attack me again (Get out of the combo chain). I think it’ll be good to use tick() in this situation but I really don’t know how to do implement it. Here’s a part of the script:

local current = 0
local previous = 0

if combo == 1 or combo == 2 or combo == 3 then
current = tick()
						
local passed = current - previous
if(enemy.Parent.Stunned.Value) == false and passed <= 0.5 then
	enemy.Parent.Stunned.Value = true; 
else
	previous = current
	enemy.Parent.Stunned.Value = false; 
end

end

If you’d be fine with whole numbers, os.time() would be an easier approach.

You’d make this by saving os.time in a variable at the beginning of a function plus however long in seconds you want an effect to last, then wait until the “real” os.time() reaches that value.

Example:

local CurrentTime
function Pause()
if not CurrentTime or os.time() >= CurrentTime then
CurrentTime = os.time() += 5
print(CurrentTime)
end
end

Hmm, can you elaborate? I’m a lil bit confused.

os.time() returns a number value that ticks up every second. Adding whatever number you want on top of it is basically doing the same thing, but without the ticking. You’re basically waiting for ‘CurrentTime’ to be lesser than os.time(), which will happen eventually due to os.time() ticking upwards by 1 each second.