Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a functional combat combo?

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)

2 comments

1

you will need to use a table with the UserInputService and store the keys

0

May I get an example if you can?

1 answer

✓ Accepted answer

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

9 comments

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.

1

Sorry, i forgot to add the keys variable. I updated it

0

There is still an error that says something on line 6 is a nil value

0

"17:23:11.466 - Players.JxstEcho.PlayerScripts.test:6: attempt to index field '?' (a nil value)"

0

Sorry again, this time it should work for sure

0

Thanks a lot, works perfectly now!

0

Np, yw

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.

0

Yes, the part where is -- Combo is what you want to happen after the player press's EEQ or the given keys

This discussion is preserved as it was. New answers, comments, and votes are closed.