Cancelling skills mid skill

So I’m making a new project and have a few methods in mind but am wondering what the best way to cancel skills mid action would be?

I thought about putting a GetAttributeSignalChanged for my stunned function with a skill cancel function in each and every skill but that could get messy and honestly wouldn’t be that good.

The issue is that almost all my skills will be able to be interrupted but they will all be very different so what happens when they are interrupted will be different, should I stray away from this and try to make a function that fits all cases for cancelling a skill?

Edit: Since I do effects on the client and hitboxes on the server I would have to let the client to know to stop the effects script from continuing it’s process as well as the server, what’s the best way to do so?

2 Likes

Possibly a Break; could work in your favor to cancel skills.

1 Like

I’m not looping anything though, both client and server parts of the skill will have a active thread with I’m sure waits etc…

Edit: I have a few ideas in my head of how to do this but they are just all not that efficient but I guess if I’m gonna have skills be that diverse then that’s the price I pay.

Sadly I barely have any clue then, I’m trying to get into the (skill making) side of scripting, just haven’t achieved it yet.
How ever, have you looked into other Developer Forum posts?

I’ve looked at a few but nothing really answers what I’m asking for exactly, thanks though. If know one has a better method then I’ll figure it out.

If you’re using a function for the skill, you could use return to end the function at a certain line

I don’t know how your ‘abilities’ function, but I think this can work for a charge / wind up type ability, (untested) hopes this helps? :+1:

--// When Ability Is Activated:

While (self.Enabled and Humanoid.Health > 0) do
self.Charging += 1
if (not self.Enabled or Humanoid.Health <= 0) then return end; --Check after + 1
if self.Charging >= 10 then
--// Ability:()
break;
end;
end;

I usually use CollectionService to put tags inside of a player whose been damaged and remove it after around 0.1-0.3 seconds, with this I can check if the player has been damaged/stunned when the skill is about to be initiated (when its about to do damage), and just use a return on it.

I have a action system that handles all actions like stunned etc… through attributes but I’m saying that alot of my skills will be active skills where you are persay firing multiple attacks but if you are hit you need to be stopped completely like your animations for the attacks, the particles tweened back etc… Should I do this through multiple GetAttributeChangedSignals or??

Obviously, this all depends on how your game’s ability system works, what types of abilities you are adding, and also how you personally want to create your game systems, but the way I would personally do it is:

Prerequisite: You must make your ability animations have Event Markers so :GetMarkerReachedSignal("MarkerName") will activate.

  1. Client tells the server that the ability has started.
  2. Server begins the ability by starting the AnimationTrack of the ability

Here’s where things begin to diverge into different paths, I have personally not tested every single one and some may not work and there is most likely more options.

Option A: Server uses :GetMarkerReachedSignal() to fire nearby clients to create a certain ability VFX when it is reached. The downside of this being clients may have delayed VFX if ping is too high.

Option B Untested: Server sends the currently playing AnimationTrack to nearby clients, then the clients creates the MarkerReached connections and the VFX once a Marker is reached. Not sure if this option works, but if it does then it should result in 0 latency between ability VFX and animations.

  1. If the player is hit, you can use a connection like ChildAdded or AttributeChanged for example, to stop the animation and disconnect connections, stopping the ability in turn. (Your stun system needs to be detectable with a connection for this.)

Also, using :GetMarkerReachedSignal() is pretty neat since you can add a Hitbox Marker Event to handle making Hitboxes.

I’m assuming you want an ability that can be interrupted. This would take a little bit of setup.

For the first part, the ability should be cast in some sort of loop or runservice event (preferably a runservice event). This way, you can disconnect the ability at will. Let’s stick with runservice. Animations don’t need to be in the runservice event because you can disconnect them already. Every frame, you will do whatever you have to do within the event.

Preferably, there will be an event to check if the user has been blocked or “stunned” (where they stop playing attacks). If there isn’t, you’d check within whatever loop you’re using. Once they’re blocked, disconnect the loop.

There really isn’t a plausible way to do this that I can think of.

Option A is what I’ve started doing already with the stunned attribute changed as a signal to stop all vfx etc… I guess this is the best way, if you want diverse skills you just gotta do alot more work.

1 Like

How did this work out for you?