I am going to make an API with lots of modules that all need access to the current player, how can I do this?

I am making modules that need access to the player. I’m not sure how Roblox’s networking works. If I like created a new string value for the current player and let all the scripts use that, would it even work? Is there a better way to do this?

1 Like

If they’re supposed to be required from LocalScripts, you can do Players.LocalPlayer. If it’s supposed to be run from a server Script, then what you’re asking doesn’t make sense. There is no “the” player from the server’s perspective, there’s just a list of Players.

1 Like

How does for example remotes work, if two clients call the same one all at once? Does the script get duplicated or something to update things for both of the players? I want my modules to work the same as a code that would be called from a remote where you have access to the local player.

1 Like

The callback would then just execute twice, once for each calling player in a separate thread.

2 Likes

Does module scripts also thread if called again with different arguments from a server script while the current process is not finished?

Probably not since assuming your ModuleScript would return a table containing functions, calling each function then would cause that function to execute from the calling environment and as many times you call a function it would just execute synchronously with you having to wait for one execution to finish for the other to start, like any standard function.

Don’t take my word for it though, I haven’t familiarized myself with Roblox for a few months now.
2 Likes

Ah, makes sense. I’ll try it out and see what results I get.

You were correct, the process has to finish or else the other request will simply not run.