Advanced Combat System Question

Hello, people of the DevForum. I just have a small question today; I was wondering if there are any well-made combat systems that are open-sourced that I could take a look at. I have no intention to copy anything in these, but I’m curious about the inner workings of some advanced combat systems as I am currently trying to develop my own. If not, it would be greatly appreciated if someone had any resources they could share on the topic of advanced combat.

Just to clarify, I don’t mean a simple system like press MouseButton1 to do an animation with damage, I know how to do that. I mean more advanced systems with well-implemented hitstun, etc.

Unfortunately you won’t find much, but you can find some if you look around enough.

Basically what I do when making a combat system as you described, is I have a float value which is my combo chain. When the player clicks I increase the chain by 1 e.g

local comboChain = 0
local Tool = script.Parent
function Attack()
	comboChain += 1
end
Tool.Activated:Connect(Attack)

Now while this works, it’s also clear that the combo will infinitely continue on if you don’t add a max amount. It also won’t even reset within a set amount of seconds. Well, let’s see if we can fix that:

local comboChain = 0
local usedCombo = tick()
local Tool = script.Parent
function Attack()
	if tick() > usedCombo + 1 and comboChain > 0 then
		comboChain = 0
	end
	comboChain += 1
	-- play animation
	if comboChain >= 5 then
		comboChain = 0
		-- You might want to add a Debounce / Cooldown timer
	end
end
Tool.Activated:Connect(Attack)

This is a lot better for a simple combo. Obviously the ‘Tool.Activated’ is not a common way of doing this I recommend using UserInputService for this.

As for stuns, you’ll need something very simple. Most common ways people do this are by adding in values into a player’s humanoid labeled ‘Stun’. So when the player clicks with ‘Tool.Activated’ you’ll want to check if they have ‘Stun’ in their humanoid before continuing through the script.

I hope this helped, if you have any other questions let me know!