Is it possible to store spells inside a module?

Greetings,

It was recommended to me to use 1 module per spell and just call upon the module when firing to improve overall performance in a game with open world combat between many ppl. And I want to do it I just don’t get how it could be done.

If I say have a spell that uses Swordphin’s HitBox Raycast module to detect a target, then apply various effects to the hit player, how could i possibly do this with a module? Is there a way to do this? Should I even be doing this in the first place?

Thanks for your time

Would I achieve the same effect as having various modules if i just had a single server script that has a bunch of onServerEvent functions?

Hello

Currently im working on a topdown rogue like game. In it there is a few dozen magic spells and effects.

There i wound the best solution was to make one module with all of the spells. Then have an module to make them out from the index in the other module.
Im not done with it (yet) but i think that the best way to control it would be that way. When your game gets big you can link the module to a model and load it from there.

and how have you stored a spell inside the module? For example something basic like a fireball. It would require spawning a part positioning it, tweening it, making a touched event etc, how does one do this with a module that’s supposed to return only 1 value?

Hello

Well here is my step-to-step implementation of it:

First we detect a click one the client:
    
    Here we have an module that sends a request-
    to the server to make the said effect.
    
    On the server it will handle the damage and hit detection.
    We the wait on the client until we get the return from the server. 
    
    Then we make the effect on the client.
    We could also make the effect on the server however i felt it was not worth doing
    when it was single player.

On the server:
    
    When we get the request we get the index and makes an raycast to hit.
    Its just important that we return as soon as possible.
    
    Here also checks are made here.

The index holds all we need:

  1. Damage and effect
  2. Distance and timeout
  3. Type and level
  4. Creation function (if we want to make multiple effects in one spell)

This work good in my example. You just have to change it a bit if you want to make it multiplayer.