i know that local scripts arent working its really easy to know but i was just wondering why is that happening? i know there is replication client server server client etc etc stuff serverside stuff blah blah blah but is there any source that i can read Why Local Scripts Arent Working In Workspace? i just want to know the reason
I just answered one of this in different thread,
See here:
PlayerGui not working - #11 by TestAccount87000.
To make a local script function, put your client script to StarterPlayer>StarterPlayerScript.
Because, localscripts are used for firing server or getting the client. You would need put a localscript, for example Inside of player service, such as startplayerscripts.
Localscripts are only meant to be attached to a player or a descendant of it, so this explains it
Think of it this way: Local Scripts are meant to talk to your specific computer or mobile device, while normal Scripts talk to the servers. The Workspace is part of the Server that gets sent to the client, so the Local Script can’t see that it is inside the Workspace, and it doesn’t know that it exists when you play your game.
A LocalScript will only run Lua code if it is a descendant of one of the following objects:
- A Player’s
Backpack
, such as a child of aTool
- A Player’s
character
model - A Player’s
PlayerGui
- A Player’s
PlayerScripts
. - The
ReplicatedFirst
service
Well, as you said, you already know, but I’ll repeat so it makes sense:
-
Server Scripts (normal scripts)
Normal scripts (aka. server-sided scripts) run, as the name already says, on the server. What does that mean? It means that they run on ROBLOX’s computers (servers). They are being hosted by ROBLOX. Your machine (the client) does not have access to write them. This means that the server scripts are read-only. Your client (ROBLOX application) can only read. -
Local Scripts (LocalScripts)
Local scripts are scripts that run on your machine. Yes, they are inside your computer, running locally. Which means that you have, technically, access to them. That’s actually how exploits work. Local scripts will only work on yourself, because they only run for you, and not for anyone else.
Alright, you already knew this. Now let’s get back to your question. Why can’t a local script run in the Workspace?
The Workspace, just like the ReplicatedStorage, the Lighting, the StarterGui, etc. is a “service”. And of course, in order for it to work, services are also divided into three categories: services for the client (that handle local stuff), services for the server (that handle the server tasks), and the replicated one(s) (ReplicatedStorage - this one is available for both client and server).
The Workspace is a server service. This means that Workspace is responsible for handling server tasks. Whatever happens in the Workspace, will influence everyone, because everyone is in that server. So if you try to run a local script, which is supposed to run locally, on the server (Workspace for example), the engine will just ignore it, because it doesn’t recognize it. The Workspace is not optimized for local scripts. You can modify the workspace with a LocalScript, but that script has to run in a local service (such as StarterGui) (and of course that it will only be visible to you). You can’t mix the server’s with the client’s services.
I hope it was clear enough. If you have any questions, feel free to ask!
Technically, LocalScripts can run under the Workspace if parented under the player’s character. LocalScripts run in a local player context, so it makes sense that they must be attached to a player in some way.
with the new script update, scripts can run anywhere, just change the run context. if you set it to client it will run for the client even if it’s placed directly in the workspace
So, LocalScripts don’t work in Workspace?