Is creating server scripts in StarterGui bad?

Why I do it: I put all of my server scripts that needs a reference to LocalPlayer in StarterGui to prevent exploiters messing with remotes.

local plr = script:FindFirstAncestorOfClass('Player')

Reason Asking: I have no clue if replicating a server script with the same code to each client would cause severe latency issues or if its minor.

If you have any information on this, whether it is a bad habit or anything please respond to this. :+1:

Honestly, it’s kinda confusing for me whether it is good or bad.

1 Like

Server scripts can not reference the LocalPlayer because they are on the server.

If you need to reference the LocalPlayer, you must use a local script.

There is no definitive way to prevent exploiters from messing with remote events from the client. Instead, you should be doing sanity checks on the server to ensure no data is being sent which shouldn’t be sent.

1 Like

It isn’t technically, Exploiters can’t open scripts, And if they “delete” the script, They only delete it for themselves, The only diffrence from startergui and serverscriptservice is that exploiters can see the script object.

Still recommend putting everything in serverscriptservice, There’s really 0 need for any serverscripts in startergui + Scripts can’t reference the localplayer, Only localscripts can do that.

You can reference “LocalPlayer” using a server script if it placed in StarterGui:

local plr = script:FindFirstAncestorOfClass('Player')

I don’t know why you aren’t doing it in a localscript, And instead using a remote event to send the information

And why not use Players service to get the player then…?

Technically you can’t reference “LocalPlayer” by using game.Players.LocalPlayer in a server script, but you still could in server script if it placed in StarterGui:

local plr = script:FindFirstAncestorOfClass('Player')
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
   -- fires everytime when a player joins
end)
1 Like

While that is a player object, is it not the same thing as the “LocalPlayer”. Clients cannot own server scripts.

In this case, you have a script running on the server, but it’s just parent to a folder under a player object.

1 Like

Many reasons for this:

-Reduce amount of remotes needed = Less Potential Exploiters Spoofing Remote Events/Functions
-No need for server checks as it is already a server script
-Prevents exploiters from changing arguments using hooking methods

Yes I understand that the player reference using the StarterGui methods is on the server. However theirs no risk from firing client from server thus you could just make almost everything server sided.

That is my point, and I was wondering if it would cause any latency issues, since the server scripts will be replicated on the server across all players.

Use playeradded.

Fair point.

I guess yeah.

TL;DR
use playeradded, it works the same, is in 1 script instead of every player has 1, its more organized, officially supported by roblox, you can even get the character every time it respawns using it.

1 Like

Always do your main code/important stuff from the server, doesnt matter if it works fine on the client. You always want to keep your game as secure as possible. I don’t see any reason using PlayerAdded in a localscript. Simply do it on the server and use remotes[do sanity checks].

She’s using a serverscript… bruh… legit…

If you have a textbox the Script will not be able to see the changes, but I dont think it’s a bad practise either.

1 Like

You cant actually make everything server-sided. I understand what you’re trying to achieve, but it’s not going to work in the way that you think it is.

This isn’t valid because you can’t get data from the client without remote events. No matter what you’re going to need to use remote events unless it’s something physics/network ownership related.

Once again, this is not valid because you can’t get data from the client without remotes. You’re going to have to do checks no matter what.

It is true that exploiters cannot change server code. But once again, it doesn’t matter because none of the code in a server script can actually interact directly with client-related functions.

Since your code is in StarterGui, I assume you’re using it for GUI-related stuff? If so, this is a really bad idea mostly because you cant actually detect any input from the client.

In the original post she said she works with a localScript

look at the title?? and she’s clearly talking about a serverscript if you took the time to read

Still irrelevant. My points were clear enough.

And yes, there are ways to get the single player from server scripts.

1 Like

your points were invalid because you’re talking about a localscript which nobody was talking about besides me in my original argument (not even the playeradded one)

now lets not argue