How to make a good stun for combats

What you should do is use CollectionService to set tags to the player whenever he is doing a certain action. For example if the player is hit you could give him the tag Stunned and check if he has the tag stunned in the fighting attack script so he can’t fight back for a moment.

local collectionService = game:GetService("CollectionService")

function attack(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
if collectionService:HasTag(char, "Stunned") then return end
-- run the code of the attack here
end

Remember, this is just a rough example of how you should approach it. Go learn about CollectionService and make sure to manipulate tags in the server.

2 Likes

How can you do that? Can you give some example please? I’m still kinda confused whth that.

1 Like

I recommend you go learn about CollectionService and take a break from your game.
I’ve already linked the api reference just above but here are some tutorials.

In short, you can set tags to objects, which means you can set tags to characters. After you would be able to check from any script if the character has the tag without having to look for any values. Its much more practical in my opinion.

1 Like

Thank you, I’ll try it some times

1 Like