How would i make combat attack canceling

In my combat system you cant attack if you are stunned ( attribute ) but how would i make ability canceling? for example in an ability where the player cant move while shooting a big laser, if they get hit from behind, the ability stops instantly and the animation stops

1 Like

When casting a move, create an attribute (boolean) in the character. Set up a listener to check if this attribute has changed. If it has, stop the attack from playing (self explanatory). Anytime someone casts an attack, have them check if the person they are attacking has the attribute and change its value.

Stopping animations:

local hum = pathToAHumanoid
local AnimationTracks = hum:GetPlayingAnimationTracks()
for _, animation in pairs(AnimationTracks) do
	if animation.Name == stopThisAnim then
		animation :Stop(speed or 0)
	end	
end

I actually implemented something like this in one of my previous games (getting ragdolled forces moves to get cancelled):
https://streamable.com/y69e4g

2 Likes

Sorry for replying almost a week late, but i would like some help. How would i stop the actual ability on server side? because abilities have hitboxes using a hitbox module on the server side, and i would really like to know

1 Like

If you are making an attack with windup just check if the boolean is still unchanged by the time you want to create the hitbox or if you are using a module/part for the hitbox you can just destroy/stop it it when the boolean is changed with a function.

2 Likes