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

How do I make a functional combat combo?

Asked by
Jirozu 71
6 years ago

I have tried to make a combo system to where if you press "Q-E-Q" In enough time to you'll do a combo, but I have no idea if I am doing it correctly. Can I get a little hand?

userinputservice.InputBegan:Connect(function(input, gpe)
    if gpe then return end;
    if input.KeyCode == Enum.KeyCode.Q then
        if transforming or kiblasting or evading == true then return end;
        if not attacking then
            attacking = true
            if tick()-attack_timer > 0.8 then
                attackstate = 0
                attacking = false
            end
            attack_timer = tick()

            attackstate = attackstate+1
            print("Punch 1")
        end
        if input.KeyCode == Enum.KeyCode.E and attackstate == 1 then
            print("Kick 1")
            attackstate = 0
        end
    end
end)
1
you will need to use a table with the UserInputService and store the keys oSyM8V3N 429 — 6y
0
May I get an example if you can? Jirozu 71 — 6y

1 answer

Log in to vote
1
Answered by
oSyM8V3N 429 Moderation Voter
6 years ago
Edited 6 years ago

This should work, its the same one i use:

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(key)
    table.insert(keys, {key, tick()})
    if tick() - keys[#keys - 2][2] < 1 then
        if keys[#keys - 2][1].KeyCode == Enum.KeyCode.E then
            if keys[#keys - 1][1].KeyCode == Enum.KeyCode.E then
                if keys[#keys][1].KeyCode == Enum.KeyCode.Q then
                    --Combo
print("Worked")
                end
            end
        end
    end
end)



Any errors, feel free to comment

0
I have one error, It's giving me the error code "13:59:28.858 - Players.JxstEcho.PlayerScripts.PlayerCombatClient:41: attempt to index field '?' (a nil value)" I have the same code you posted but I added a "local keys = {}" due to the script not knowing what "keys" is. Jirozu 71 — 6y
1
Sorry, i forgot to add the keys variable. I updated it oSyM8V3N 429 — 6y
0
There is still an error that says something on line 6 is a nil value Jirozu 71 — 6y
0
"17:23:11.466 - Players.JxstEcho.PlayerScripts.test:6: attempt to index field '?' (a nil value)" Jirozu 71 — 6y
View all comments (5 more)
0
Sorry again, this time it should work for sure oSyM8V3N 429 — 6y
0
Thanks a lot, works perfectly now! Jirozu 71 — 6y
0
Np, yw oSyM8V3N 429 — 6y
0
I don't understand, where you put "--combo", what are we supposed to do there? Play a animation? Connect a function to the part that touched the other player and damage the other player's humanoid? Please explain. FireyMcBlox 134 — 6y
0
Yes, the part where is -- Combo is what you want to happen after the player press's EEQ or the given keys oSyM8V3N 429 — 6y
Ad

Answer this question