#Module bug

1 messages · Page 1 of 1 (latest)

honest dirge
#

So ive had a lil bug

#

im trying to try and change a can attack value but it doesnt change a thing

#

function CombatStateController:Stun(character, duration, walkSpeed, jumpHeight, canAttackDuringStun)
if not character then return end
self:InitCharacter(character)

local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then return end

local endTime = tick() + duration
local state = states[character]
state.StunnedUntil = math.max(state.StunnedUntil, endTime)

if canAttackDuringStun == false then
    state.CanAttack = false
end

if not state.OriginalStats.Stored then
    state.OriginalStats = {
        WalkSpeed = humanoid.WalkSpeed,
        JumpHeight = humanoid.JumpHeight,
        Stored = true
    }
end

table.insert(state.MovementQueue, {
    EndTime = endTime,
    WalkSpeed = walkSpeed or 0,
    JumpHeight = jumpHeight or 0
})

humanoid.WalkSpeed = walkSpeed or 0
humanoid.JumpHeight = jumpHeight or 0

task.delay(duration, function()
    if not states[character] then return end
    local now = tick()
    local remaining = {}

    for _, entry in ipairs(state.MovementQueue) do
        if entry.EndTime > now then
            table.insert(remaining, entry)
        end
    end

    state.MovementQueue = remaining

    if #remaining > 0 then
        table.sort(remaining, function(a, b)
            return a.EndTime > b.EndTime
        end)
        humanoid.WalkSpeed = remaining[1].WalkSpeed
        humanoid.JumpHeight = remaining[1].JumpHeight
    else
        humanoid.WalkSpeed = state.OriginalStats.WalkSpeed
        humanoid.JumpHeight = state.OriginalStats.JumpHeight
        state.OriginalStats.Stored = false
    end

    if state.StunnedUntil <= now then
        if canAttackDuringStun == false then
            state.CanAttack = true
        end
    end
end)

end

#

btw this is the script where the canatttack is found