Ok, I ended up running into another issue…
if not canattack then
timer.delay(10, false, function() canattack = true end)
print("cant attack")
end
This code is set up to create an attack delay^^
if action.id == hash("key_z") and action.released and facingright and onground and canattack then
print("attack recieved")
print("attackright")
local pos = go.get_position() + vmath.vector3(160, 30, 0)
local id = factory.create("#attack", pos)
go.animate(id, "position.x", go.PLAYBACK_ONCE_FORWARD, pos.x + 1500, go.EASING_LINEAR, 0.8, 0, function()
go.delete(id)
end)
canattack = false
end
This is the attack code^^
I did not get any errors but the gameplay is like this:
- When I click “z” the character attacks.
- 10 seconds pass until the character can attack again.
- Once 10 seconds has passes the character is then able to attack for another 10 seconds rather than only being able to attack once, then the cycle repeating.
Any insight would be appreciated!
I may have explained my situation poorly, if you need more information please let me know.
Thanks,
V