I’ve recently been working on creating magic such as a basic fireball and I have learned how to do so using TweenServices. Now I would like to go a step further to adding key binds and stats to the fireball. The stats in the fireball would be things such as damage, the key bind, the distance, etc. I know that I would have to use a module script for this however, I’m not sure how to go about a way to make an organized system for this that is readable and easy to edit. Note : I don’t want the code on how to do it… I just want to know how the system would work. Example code might help me learn however, please don’t just give me the straight code.
Personally since this is similar to guns i would use the same format. Add more stats to this but this is the gist of it.
local stats = {
Damage = 16;
Range = 100;
Animations = {
Fire = "rbxassetid://123"
}
}
return stats
There is no built in function in roblox called damage, range, or animations though…
Those aren’t functions, it’s a table. You’d access damage and range from the table in the module.
But you can’t just say damage and have the damage actually happen… you can’t say range and have a range frameworked. I feel like I’m missing something… please explain.
I think it is unclear what you want. This is just to store the statistics to be used in a function that you create. These aren’t the functions themselves, you have to write those and then you can use these statistics inside the function. If you’re looking to organize different types of magic I’d look into OOP here.
I’m familiar with OOP, I finally realized what you are saying… thanks. How would I make functions to work with the stats? This is getting kind of irrelevant to the post but if you could follow me up in PMs I would be more then grateful.