How to make a combo system

So I think the terminology is dial-a-combo system? Which is a pre-set string or combination that must be performed in order in a certain amount of time to do something well I’ve been trying to do this, but can’t seem to get it working quite right :confused:

Currently whenever I input a key it instantly resets the combo as it doesn’t exist in the module script so if I hit E it resets it which means I’m never gonna be able to input EER as it resets as soon as I try to. So if it’s possible can someone help me fix this? thanks :slight_smile:

This probably isn’t the most efficient way, but this is just how I’ve managed to do it so far with what I know.

  • My script
local Combo = ""

event.OnServerEvent:Connect(function(player, Action, Input, Plr, V1, V2)
	local character = player.Character
	
	if Action == "Combat" then
		Combo = Combo..Input
		Hitbox[plrData[Plr].Moves[Input].type](plrData[Plr].Moves[Input].dmg, plrData[Plr].Moves[Input].kb, nil, character, nil)
	elseif Action == "Block" then
		
	end	
	
	if Combo == plrData[Plr].Combos[Combo] then
		--Do Stuff--
		Combo = ""
		print("Combo Reset")
	else
		print("Invalid Combo")
		Combo = ""
	end
	
	spawn(function()
		local oldCombo = Combo
		wait(1)
		if Combo == oldCombo then
			Combo = ""
			print("Combo Reset")
		end
	end)
	
end)
  • My moudle
		Combos = {
			["EER"] = { --Combo Pattern
				--Move Info/Stats
				anim = "";
				dmg = 0;
				kb = 0;
				height = 0;
			};

Where are you detecting what key is pressed? Include that please.

You could add a value, model, or whatever as children of the player to know that a combo can be performed, of course you will also use Debris:AddItem to remove said value to prevent the combo from lasting forever.

oh I have this

local controls = {
	["E"] = function(Input) 
		anim.E:Play()
		event:FireServer("Combat", Input, script.Name) --script.Name is the name of the character so I know which
		--character I need to get in the module script (the character is the fighter and not the players character)
	end,
	["R"] = function(Input) 
		anim.R:Play()
		event:FireServer("Combat", Input, script.Name)
	end,
	["T"] = function(Input) 
		anim.T:Play()
		event:FireServer("Combat", Input, script.Name)
	end,
	["F"] = function(Input) 
		anim.F:Play()
		event:FireServer("Combat", Input, script.Name)
	end,
	["G"] = function(Input) 
		anim.G:Play()
		event:FireServer("Combat", Input, script.Name)
	end,
	["H"] = function(Input) 
		anim.H:Play()
		event:FireServer("Combat", Input, script.Name)
	end,
	["Q"] = function(Input) 
		anim.Block:Play()
		event:FireServer("Block", Input)
	end,
}

UIS.InputBegan:Connect(function(Input, Game)
	if Game then return end
	if controls[UIS:GetStringForKeyCode(Input.KeyCode)] then
		local key = UIS:GetStringForKeyCode(Input.KeyCode)
		controls[UIS:GetStringForKeyCode(Input.KeyCode)](key)
	end
end)

Someone recommended me this method after they saw the mess I had

Here’s something to get you started.

local UIS = game:GetService("UserInputService")
local keys = {}

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.R then
                    -- do the combo
                end
            end
        end
    end
end)
6 Likes

Hmm I’m not quite sure how this is supposed to work, but I don’t think this is what I’m trying to do lol

It just detects if E E R is pressed and then does the combo.

You can add it below the other function.

So hmm if I wanted to add multiple combos then I’d just duplicate that?

Sorry for bumping but yes, you would just duplicate.

2 Likes