Why not just make everything server sided?

Forgive me if this is in the wrong category, I don’t post very often on the forums.
My question is why should I use remote events or local scripts at all when it’s possible to access all the player’s attributes from the server? Wouldn’t it just be most secure to have the server doing all of this?

Like for example:

Playertable = {}
Players.PlayerAdded:Connect(function(player)
	table.insert(Playertable, player)
end)

for i,v in pairs(Playertable) do
    local touchedConnection = v.Touched:Connect(function(hit)
        —do something
    end)
end

1 Like

Touched events are actually handled by clients still–even if you attach the listener on the server.

The client will send a network call saying that they touched a specific part.

And not everything can be done on the server. You should probably be reading anything that you can from the server, but sometimes you need to get something from the client–though be careful how you use it.

Also there are lots of things you might want to handle entirely on the client like UI animations, interactions with client side stuff like dialog, etc.

Also I suggest setting your table value’s to weak because you are going to expose a memory leak in this code. (Or, when a player leaves, you remove them from the table).

2 Likes

Because handling GUIs from serverside isn’t very performant and also there are cases where serversided code is just not a valid option.

Take TextBox.Text property for example, when player writes on it, it doesn’t replicate to server so you have to handle FocusLost and property change detection from LocalScript and notify server via RemoteEvents.

Another case is User Input Detection via UserInputService. This service’s event don’t work in ServerScript for obvious reasons and you need to user a localscript and remotevents to send info about player’s input to server.

1 Like
  1. Making everything on server side will decrease a lot the performance of your game, it will be really laggy.
  2. Some things only work on client side like, keybind function or must to be made on client side like settings (mute music, enable/disable shadows ect).

Your first statement is wrong, as it all depends on what you do inside the script, not what type of script you are currently using (localscript/serverscript).

So in the case of humanoid touched events the way that I’ve done it would be most secure? Even though it doesn’t prevent a client from faking a touched event it prevents them from doing anything else beside that? I’ve been trying to make my code secure from the client by serversiding everything that could possibly give the client an advantage. UI it makes sense not to do that because it doesn’t give the player an advantage

people would start exploiting and stuff including someone using backdoor

UI needs to function on client, everything else can function on server but not recommended.