Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

[SOLVED] Any way to require a different module each time?

Asked by 9 years ago

So, I want to hide the code for one of my scripts by requiring a module by ID, how can I make it require a different one each time? The reason I want to do this is because if it requires the same module then each player's variables get redefined (this is for a leaderboard) causing the player that last joined to get their deaths changed each time someone dies! This is really annoying and since ROBLOX have made this change I haven't found a way around this. If this is impossible I guess I'm just going to have to keep the source code in the actual script. I just hope there's a way...

2 answers

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

An important feature of modules is that if you require the same module, you get the same object returned.

The act of requiring a module shouldn't do much -- if it does, and that's a problem, then you haven't designed your module looking towards the future.

If there's any reason you need to use a "separate" copy of a module multiple times, it should be returning a function which does that setup, instead of that setup just being done in the body of the module.

Ad
Log in to vote
2
Answered by 8 years ago

What the guy that answered said!

Answer this question