Question regarding the Client-Server-Model

Hello :smiley:

I have trouble understanding the Client-Server-Model and the respective behaviour of scripts, localscripts and the workspace.

On the reference page for the Client-Server-Model it is stated, that “scripts only run on the server”.

On the reference page for Scripts however it is stated, that " Script object is a descendant of the Workspace or …"

So far I considered the workspace to be client-sided, because:

  • When you test your game in Studio, you will only be shown what the players client can access - including workspace
  • When you test with mulptiple player-instances you can make changes in one workspace which are not visible to the other client.

Now I am confused. Shouldn’t then only LocalScripts run in Workspace? Is it safe to have Scripts in Workspace?

I hope you can help me clear up this confusion :smiley:
Thanks

I think you’re confusing yourself because you’ve taken the quote out of context. The second extract you referred to, “Script object is a descendant of the Workspace or…”, only makes sense when with the rest of it’s sentence. That is the condition that the script must meet so that it can be executed and ran, meaning any script within the workspace or ServerScriptService (the rest of that line where the quote cuts off) will be able to run as long as it’s not disabled.

Also, the workspace is not client sided, but what the player sees is. Imagine I owned the Mona Lisa. If I gave 10 people a photo of it, they could do whatever they want to that photo. However, the mona lisa is still in tact and the other photos do not get changed. This is the same principle for the server, but that “picture” is getting sent to everybody multiple times a second, incase any updates happen.

3 Likes

Thanks for the quick response :smiley:
I still am confused, but I will play around a bit and let it sink in. If I find a way to either understand this or give my problem better phrasing, I will post again.

Until then, thank you :smiley:

Its safe to have scripts in workspace. But its nicer to have them inside of serverscriptservice because i think that loads faster. And its ugly seeing scripts in workspace.

The workspace is not client sided, you can delete parts and such on your client but that wont replicate to the server, because you dont own the server, only changes made on the server (with server scripts and stuff) will replicate to everyone else.

Scripts are code that are ran on the server. LocalScripts are code that run on the machine on an individual client.

The server will only run the script however if it is a descendant (located somewhere inside) the Workspace or ServerScriptService.

By default when you PlayTest your game, you will view the perspective of your own client. You can however change to the perspective of the server, to see what the server sees.
https://gyazo.com/b85865ce196ef98f77909dfd68bf8d99
You should notice that the colour blue is associated with the client, and the colour green is associated with the server. When I change perspective to the server the blue border around the screen becomes green.
image

1 Like

This was really helpful!
Thanks you so much :smiley: