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

How would i get this combo system to work?

Asked by 9 years ago

so im trying to make a combo system for my game. I want to make a script that fires when the player hits the mouse buttons in a certain order consecutivly. For example, i want a combo like Mouse1+Mouse2+Mouse2 = Combo. When they enter in this order it wil fire. This is what i have so far

player = game.Players.LocalPlayer
uis = game:GetService("UserInputService")
uis.InputBegan:connect(function(key,procy)
    if not proc then
    local keys = uis:GetKeysPressed()
  local needed = {"Mouse1","Mouse2","Mouse2"}
        for i ,v in pairs(keys) do
            if keys == needed then 
  print("I Got a Combo")
            end
        end
    end
  end)

This doesnt work at all and im not sure if I'm even doing it correctly >.>

1 answer

Log in to vote
2
Answered by
Hero_ic 502 Moderation Voter
9 years ago

Its not the best script but it works.

local combo = 0 --First I will make combo variables
local combo_limit = 1 --seconds until time left to press ends
local combo_delay = .2 --seconds until the combo happens
local combo_delay2 = .2 --seconds until the combo happens
local combo_delay3 = .2 --seconds until the combo happens

game:GetService("RunService").RenderStepped:connect(function() --next we get renderstepped
    if combo > 0 then --if its greater then 0 if it waits combo limit it = 0 again
        wait(combo_limit) 
        combo = 0
    end
end)

game:GetService("UserInputService").InputBegan:connect(function(input , procy) --get input begin for combos
    if not procy then
        if input.UserInputType == Enum.UserInputType.MouseButton1 and combo == 0 then --when we press this it gives us another combo same with the ones below
            wait(combo_delay)
            combo = 1
            print(combo)
        end
        if input.UserInputType == Enum.UserInputType.MouseButton2 then
            if combo == 1 then
                wait(combo_delay2)
                combo = 2
                print(combo)
            elseif combo == 2 then
                wait(combo_delay3)
                combo = 3
                print(combo)
            end
        end
    end
end)

if this helped please (upvote) and accept :D ~KIHeros

Ad

Answer this question