hello devforum :)!
i am currently in a bit of trouble making a fighting game with abilities: i am handling the hitboxes on the server and the visual effects on the client.
my first plan was to communicate to clients with :FireAllClients() and play the effect however you can’t pass functions as arguments, and since the modulescripts that store the ability functions are in ServerStorage i can’t get the function directly from the client by indexing a string.
i have thought of making another folder of module scripts that contain the visual effects so then i can:
get the function directly from the client by indexing a string
but this means i have to make double the instances which is most likely not the most efficent way for readability and handling lag, what do you recommend?
I recommend rethinking the problem. Rather than sending a function, you should only have one function, on the client, since only the client needs to do visuals for anything. So getting the function by indexing a string isn’t actually a bad idea, but of course I don’t know the rest of your setup. If there’s only one or two visual effects, you might even just make separate RemoteEvents for each weapon or whatever. Ultimately, it’s a matter of memory rather than performance, and the impact shouldn’t matter too much.
You could either make one event with the parameters in a table, use multiple events (I don’t personally recommend this one) or divide each code block in one event by recognizing each with a string, for example, FireAllClients(“Effect1”), then the local script checks with an if statement which block to run.
this is what i want to do however i’m worried doubling the modulescripts will impact memory/performance, it also won’t be good for readability and will end up confusing
You could make the damage and hitboxes only in one module script though, right? The module scripts for each character can pass information with tables, in one of my games I first pass information to the Hitbox module then the damage one, but you could also make them one.
The original module script for character pass the other module the effect information so when the damage fires the effects also follow.