so in my GUI i uses a lot of Server Script in order to prevent exploiter from exploiting my game,
i usually uses it for something like Changing Weapons, Damage, etc.
but for Visual i use Local Scripts, is it Okay to use Server Script in a GUI? the GUI is not broken it works as intended and cannot be exploited, i tried it in studio and in-game everything’s work fine.
but maybe later in the near future it can cause lag? or anything? since later my game will have a lots of players like 30 - 50 because its an Open World RPG. and do you have any suggestions in order to prevent lag?
like in my last game named “Gun Simulator” i uses Tween for the bullets and it lags! like really LAGGY. i dont want that to happen again.
if it isn’t a local script for the gui, won’t it show to everyone if you open a component in it?
Otherwise if the gui is just something like" total players in server", or " these people completed the game" etc. then use a server script
Also , for reducing lag with bullets try this
community resource, it uses raycasting and it’s less “laggy”
edit* : For changing weapons etc. unless you scripted to allow it being used in a server script, you should use a local script.
This is what you’re looking for
To optimize your game , and when to use a local script rather than serverscript.
Server-side scripts are only used for GUIs that are supposed to be shown to everyone
If you’re using a server-side script for a Menu GUI or any other GUI that is supposed to only be used by one player then client-side scripts are the option
Since server-side scripts replicate to everyone as the code happens on the server
Yeah, if its for the whole server to see changes, then use server scripts. If its for 1 user, then just use client (local) scripts.
well, its for an inventory GUI.
big oof for me, i will need to rewrite the whole code,
It’s ok to setup GUIs or add etc using Scripts, but when it comes to player input and non-replication you’ll definitely need to use LocalScripts.
You can always use RemoteEvents/RemoteFunctions for client->server or server->client communication, just remember the golden rule; never trust the client
So you mean, it’s OK as long as it’s not lag and work properly?
if it is, then i don’t need to change.
It may matter on the FPS of the client, this could vary.
If you’re not relying on player input or anything else which is only accessible via LocalScripts then it should be all fine.
I wouldn’t neccessarily handle everything on the server, the client needs stuff to componsate for their FPS.
It’s a viable option, though I wouldn’t recommend it.
Rewriting code to be used by a LocalScript isn’t that hard as you may think
Correct, serverscripts can can cause too much load on the server and different clients can have actions replicated separately on themselves, meaning they will if used, work better than with a singular script performing all actions for the clients,
as it’s not necessary for example, that all clients will have 60FPS or something ,so localizing some scripts does in a way improve the latency of your game
It’s really case-sensitive.
If you really want to use a server script, use events.
Server scripts will show everybody the same GUI, while local scripts stay on your client and your client only.
Although, server scripts can be very helpful in other cases.
Although using local scripts and remote events is better, using server scripts won’t change a gui for everyone. (It will replicate to the server, but the gui changes will only happen to the player’s copy of the gui.)
Yea, I just realized in heinz site that’s not exactly how replication works.
Thanks for correcting me