Lately, I’ve been rewriting some mechanics for my game and using modules for my tools instead of scripts. Well, everything was fine and working, but last night the modules would run, but this morning, functions like .Equipped, .Unequipped, and .Activated weren’t running, while the top of the module ran. Note that I printed at the top of the module script and in all functions inside of the module.
Right now, the only conclusion you may come up to is that something is yielding the code. Well, I closed Studio and did some other stuff and when I came back, IT WORKED AGAIN??? I didn’t touch a single thing, trust me. I have a game with an average of 400-500 concurrent players and almost 3 years of scripting experience. So please, trust me, I don’t slop my code around or anything. I even saved the game and what not, so it didn’t go to a previous version where it was broken or something.
Also, this might be a factor, but Team Create is enabled so my testers have access to the place.
Could you show relavent code in your modules that could be the problem? Have you tried printing inside the module to see where it gets to, or print before and after you require it?
Yeah, I’ve tried that, but it’s not just a module script, it’s all of them that set up the tools, except for the client side. And yes, it runs the module every time but the functions inside of them sometimes simply do not run. Right now, though, the modules work, but I know later they’re going to shut off again. This has been happening ever since the past updates on Studio too.
The way I made them work again was restarting studio. I didn’t touch any code; I swear up and down.
Sometimes roblox studio is, weird. Or maybe it’s simply a coincidence that it fixes when you restart. It could also be that studio runs faster on the first run, because there isn’t as much memory being used as there is when you’re on your 15th playtest. So theres probably some inconsistency in your code. (which I still haven’t seen yet-)
I play tested once, and it didn’t work. I restart studio and I play test once and it works. But I’m going to test a few times, and I’ll see how it goes.
Alright, just play tested 3 times, and all of the times were successful. I even restarted studio just now, and it STILL works. Maybe Roblox just resolved it
Do you think re requiring it should work? Like not have it a variable at the way top of the script? Since it seems to work when I require it when I need it.
Alright, so I fixed it, and all you have to do is require the modules WHEN you need them, so when you’re connecting the tools, you have to require the modules. I had my requires at the top of the script, so I think the module scripts somehow just got old, I don’t know
Also, if you’re firing a remote event to the client to connect a module script to a tool, make sure to put a task.wait() after parenting the tools and before firing the remote events.