if i have a script for when the player press x it prints (key pressed). Would i use a local script and where would i put the script. I’m still a bit lost with where and what type of scripts to use for specific stuff.
LocalScripts run on the client (player’s device), while regular Scripts run on the server. To detect things like key presses you’ll need to use a LocalScript.
See here for a list of places LocalScripts can be stored. See here for a list of places regular Scripts can be stored.
- Local script handles everything LOCAL (specific to the player) and must be descendants of the player. What’s written in local script can only access the local player and cannot affect other players, use it for UI, animations and that kind of stuff that does not need to be shared among players.
- Scripts on the other hand are handled by the Server and have access to everything, they can manage any player, handle data and anything that is done in it is replicated to every player. You’ll put anything important like data manipulation or anything that needs to be shared among player.
Do note that scripts can be “dangerous” if they are not secured, and as I mentioned earlier, if someone somehow manages to trick the script into doing something malicious, this could lead to some bad stuff - Module script is another type of script, it’s basically a “piece of code” where you can store some info/ functions to access from pretty much anywhere by doing
require(moduleScript).thing
which is very useful if you don’t want massive scripts/local scripts. Module script will be ran local if the require is from a local script and server side if it’s run by a normal script (server script).
For local script to communicate toward server / server to client (for example, if you need player’s data, but can’t get it as you’re in a local script) you can use remote events / remote functions RemoteEvent | Documentation - Roblox Creator Hub
Just keep in mind that local means it’s player’s only and is on the player’s computer while normal scripts are on the server and cannot be seen by players.
Hope that helps, don’t hesitate asking if you need more help about that, it’s very important to understand those concepts before starting projects.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.