The code is too simple , but perhaps i don't see something ?
function Script:UpdateWorld()
self.delay =Time:GetCurrent()- self.attackDelayTimer
if self.enabled == true then
--timer
if Time:GetCurrent()- self.attackDelayTimer > self.attackDelay then
self.canAttack = true
self.attackDelayTimer = Time:GetCurrent()
end
if self.canAttack == true and self.state == "idle" then
self.state = "attack"
end
self:animations()
self.canAttack = false
end
end
function Script:animations()
if self.state == "attack" then
self.animationmanager:SetAnimationSequence("attack",0.02,2000,1,self,self.EndAttack)
--self.animationmanager:SetAnimationSequence("attack",0.02)
end
if self.state == "idle" then
--self.animationmanager:SetAnimationSequence("walk",0.03,50,0,self,self.EndIdle)
self.animationmanager:SetAnimationSequence("walk",0.03,50,0,self,self.EndIdle)
end
end
function Script:EndIdle()
end
function Script:EndAttack()
self.state = "idle"
end