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
01 | player = game.Players.LocalPlayer |
02 | uis = game:GetService( "UserInputService" ) |
03 | uis.InputBegan:connect( function (key,procy) |
04 | if not proc then |
05 | local keys = uis:GetKeysPressed() |
06 | local needed = { "Mouse1" , "Mouse2" , "Mouse2" } |
07 | for i ,v in pairs (keys) do |
08 | if keys = = needed then |
09 | print ( "I Got a Combo" ) |
10 | end |
11 | end |
12 | end |
13 | end ) |
This doesnt work at all and im not sure if I'm even doing it correctly >.>
Its not the best script but it works.
01 | local combo = 0 --First I will make combo variables |
02 | local combo_limit = 1 --seconds until time left to press ends |
03 | local combo_delay = . 2 --seconds until the combo happens |
04 | local combo_delay 2 = . 2 --seconds until the combo happens |
05 | local combo_delay 3 = . 2 --seconds until the combo happens |
06 |
07 | game:GetService( "RunService" ).RenderStepped:connect( function () --next we get renderstepped |
08 | if combo > 0 then --if its greater then 0 if it waits combo limit it = 0 again |
09 | wait(combo_limit) |
10 | combo = 0 |
11 | end |
12 | end ) |
13 |
14 | game:GetService( "UserInputService" ).InputBegan:connect( function (input , procy) --get input begin for combos |
15 | if not procy then |
if this helped please (upvote) and accept :D ~KIHeros