I’m making a game where players can use skills, and each skill is stored in Replicated Storage as a module script. Currently, I have an input handler script, which fires to the server which then tells all clients to use the same module. I want to make it so that I can cancel a module from running if, say, a player is hit while using a skill. I’m using task.spawn(module.function) and task.cancel() to cancel the module. But I need a way to identify the module that is currently running on any client or server. Like I need to be able to tell all players the cancel the same module regardless of where I’m telling them from—any client or server—and a simple way to store it. Would I use a dictionary on each client?
Essentially what is the best way to have a universal id and store it?
When you cancel the ability, kill the thread and also run a cleanup function for the ability. Basically the cleanup function will disconnect all connections, kill all threads, destroy all parts, etc.
Easiest way I found is using CollectionService to add a tag onto a players primary part where the tag name is the ability. When you start an ability you add the tag to the victim player, and when the ability ends you remove the tag. (Basically a load in/load out function w/ collection service) Then from there it’s pretty straightforward to remove any effects on that client for every other client.
That’s really interesting. So I don’t need to store modules in a table or anything? All I need to do is have events for when tag is added or removed to connect a cleanup function and just add/remove tags whenever I want to start/end an ability?