You read the title… I’m pondering what method would be the best performance wise and cleanest in my module scripts. I’ve been researching _G
and shared
but I’ve seen support and criticism on both sides on whether its efficient or not.
Firstly, I think I need to explain the scope of my module scripts. I’m not sure if I’m doing this efficiently or if I’m making a major mistake but I’ve noticed that some things that are bringing down the performance (speed) of my module scripts… I think. My explanation may come off as vauge… just bear with me…
Storage method
There are stats (string value instances with attributes attached to them) which are located inside of ServerStorage. These are essential to the module scripts, since most of the functions inside of said module scripts revolve around retrieving these stats multiple times. I should also note that the client is the one who is running these module scripts- I don’t know if thats a problem, but whenever I run the module scripts on the client it seems WAY faster than the server and I like that. Also animations playing and animation event functiosn are way more accurate on the client.
Retrevial method
To get these stats, I have functions inside of the module script which find the afformentioned stats from eariler from given criteria. Usually, they’ll have to fire a RemoteFunction from client to server in order to get it, which I feel like is the crux of the problem. I don’t think this is relevant but on each of these retrevial functions I have a if runService:IsServer() elseif runService:IsClient() end
or vise versa on each of them. These stats will then be used in both calculations via the server or appearences on the screen when you click buttons via the client.
Yet again, I was debating between using _G
and or shared
, but I’ve seen grand controversy surrounding each. Should I cut back on remote functions or something? It seems to not be working fast enough. Please let me know.
P.S. I may follow up with a question on how to optimize further things if you’re up to it…
P.S. P.S. If you need further or clearer explanations on certain things I’ve said, just say so because I was like half asleep writing this and I can’t tell if I’m ingenius or retarted in my explanations.