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
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
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)
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.
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
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)