Need help for combo system

Well, hi
i’am making a game and im trying to make a combo system(must be server sided).
I’ve never done any and that why today im asking for your help.
since 3 days im thinking about how i could make one but still nothing

here’s my current script :

local cache = {}
local count = 0

game.ReplicatedStorage.Remotes.Attack.OnServerEvent:Connect(function(executor, Type)
    local tool = executor.Character:FindFirstChildOfClass("Tool")
    local Track = cache[executor.UserId]
    
    if tool and not executor.Stats.IsCooldown.Value == true then
        if not Track and Type == "M1" and count == 0 then
            cache[executor.UserId.." M1"] = executor.Character.Humanoid.Animator:LoadAnimation(tool.Attack.Slash1)
            Track = cache[executor.UserId.." M1"]
            Track:Play()
        end
        
    end
    
end)

so im asking to yall if you could help me

thank

1 Like

how do you want the combo to work? is it a certain amount of M1 clicks? or different keys?

certains amount of M1 Clicks
(sorry for the late reply tho)

ok i found the problem i think, leme open up studio and ill test it rn

last question , is it a tool if not how is it being activated?

yep, i use a tool because its way easier

You are not activating the tool, just when you use the tool do this function below:

tool.Activated:Connect(function()
-- do stuff here
end

i know, but i need to make a combo system like :
1 click = animation if player is keep clicking then it run another animation

Alright hey, so your logic would probably be something as the following:

1. Make a combo variable
2. For each hit add +1 to the combo variable
3. You could use tick() to compare the last time they clicked with the current time they click, that will help you with figuring out what attack they want to do.

Example of tick:

local t = tick()
wait(2)
print(tick() - t) --The time elapsed since t was made

4. Play a different animation depending if you’re still in the time limit you want to have since you last hit and depending on your combo var, if the time is greater than your limit reset your combo to 0.

Hope I could help you!

1 Like

Thank ! you helped alot, btw im running everything on the server, and im getting tool.Activated from client
how could i improve it?

Glad to hear it helped you alot, i’d be happy if you could mark it as solved!

Also do you mean that almost everything runs on the server? That’s good, because it gives protection against exploiters!

If you’re talking about your Code in general, its fine as far as I can tell :slight_smile:

Well thank, so if i resume right ill just have to

local t = tick()
--do stuff
if (tick() - t) >= 1 then
   -- do combo
end

Yup you can try that out! If you still have any trouble lemme know!

ok so, i have a problem and the problem is that i dont know how to organize it like :

-- // TO TRAIN MYSELF WITH COMBO
local mouse = game:GetService("Players").LocalPlayer:GetMouse()

mouse.Button1Down:Connect(function()
	local combo = 0
	print("First")
	local t = tick()
	if (tick() - t) <= 1 then
		print("Second")
	end
end)
1 Like