#Combat system m1's working weirdly

1 messages · Page 1 of 1 (latest)

twilit cape
#

Trying to make a combat system, but i find that when i spam m1 instead of the animation ending and the other animation starting, it bugs out and they both try and run or only 1 or 2 run and the rest dont

function Fists.LightAttack(character : Model, count : number)
    
    local humanoid = character.Humanoid
    local hrp = character.HumanoidRootPart
    local bindableEvent = SS.Events.CombatFinished
    
    local animator = humanoid:FindFirstChildOfClass("Animator") :: Animator
    
    if not animator then
        animator = Instance.new("Animator")
        animator.Parent = humanoid
    end
    

    if count == 1 then    
        local track = animator:LoadAnimation(animations[count])
            
        track:GetMarkerReachedSignal("AttackEnded"):Connect(function()
                
                
            track:Stop()
            bindableEvent:Fire(character)
                      
        end)

        track:Play()

    elseif count == 2 then
        
        local track = animator:LoadAnimation(animations[count])

        track:GetMarkerReachedSignal("AttackEnded"):Connect(function()

            track:Stop()
            bindableEvent:Fire(character)

        end)

        track:Play()
        
    elseif count == 3 then

        local track = animator:LoadAnimation(animations[count])

        track:GetMarkerReachedSignal("AttackEnded"):Connect(function()
            track:Stop()
            bindableEvent:Fire(character)

        end)

        track:Play()

    elseif count == 4 then

        local track = animator:LoadAnimation(animations[count])

        track:GetMarkerReachedSignal("AttackEnded"):Connect(function()

            track:Stop()
            bindableEvent:Fire(character)

        end)

        track:Play()
    
    end

noble shale
#

why are you loading a new copy of the animation every time wat

twilit cape
#

what do you mean?

noble shale
twilit cape
#

oh animations is a folder count is the index

#

so animation 1 is the 1st 2 is the 2nd and 3 is the 3rd etc

noble shale
#

you have no debounce/cooldown

#

track.finished:wait etc

#

maybe its in your bindable event who knows 🤷

#

is this your first time scripting something?

twilit cape
#

nah

#

but first time scripting a cs

noble shale
twilit cape
#

sumit like this:


local track = animator:LoadAnimation(animations[count])

track:GetMarkerReachedSignal("AttackEnded"):Connect(function()

    track:Stop()
    bindableEvent:Fire(character)



end)


track:Play()

noble shale
#

can't hold your hand every step bruh

noble shale
twilit cape
#

huh

twilit cape
#
local action = {
        
        m1 = animator:LoadAnimation(animations["1"]),
        m2 = animator:LoadAnimation(animations["2"]),
        m3 = animator:LoadAnimation(animations["3"]),
        m4 = animator:LoadAnimation(animations["4"]),
        
    }
    
#

i appreciate you