Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get this code to check for a sequence of inputs rather than a check for all inputs at once?

Asked by 6 years ago
local function LightAttack(actionName, inputState)
    if crouch == true then
        s2 = true
        if s2 == true then
            if script.Parent.HumanoidRootPart.Orientation.Y == 0 then
                if leftValue == 1 then
                    s6 = true
                    if s6 == true then
                        if Enum.UserInputState.Begin and s2 == true and s6 == true then
                            animTrack5A:Stop()
                            animtrack236:Play()
                            s2 = false
                            s6 = false
                        end
                    end
                end
            end
        end
    end
    if animtrack236.IsPlaying == false then

So yesterday, with another user's suggestion of using debounces on the inputs, I was able to get this code for special attacks working properly. There's a problem, though: with this current code, the move won't trigger unless both left and down are pressed, which is not what I'm looking for. Ideally, the code should give a player a small window of time to press the button sequence of down, left, and Z(or A) to do the move. I've already tried putting in waits and whiles within and after the code, but all that's done is either bring back the original problem of this and another animation playing over each other, preventing a certain animation from playing altogether, or make a different animation play twice after the delay. I have also tried a suggestion from another user to make s2 and s6 actual instances, and have another script act as the delay for these values, but that hasn't worked, either. Anyone know how I can fix this so that the variables s2 and s6 stay true for a certain duration after the button sequence is pressed?

Answer this question