Server scripts will run anywhere the server has access to, but they will only run on the server-side, and the server script replicated to the client will sit there like a text file.
Yes, but the goal of why Iâm doing this is to remove server check since it already in the server and by having the server script in StarterGui. Allows you to have the âLocalPlayerâ, whenever I need to get data from the client I already have the âPlayerâ so I can just fire from the server to client.
Totally agree.
Also, itâs important to mention that -
When doing sanity checks, DONT try to prevent the exploiter from doing what hes doing. That wonât help you. Theyâll always find their sneaky ways.
Focus mainly on making them impenetrable, meaning - if thereâs an item that costs 100 Cash, donât let them get it if they have insufficient amount.
Youâre going to end up having to do it regardless, I promise you that. Try it out yourself and youâll see what we all mean.
And if itâs on the server anyways just do what @Nerbzzz initially mentioned with PlayerAdded in a script inside of ServerScriptService.
Could you not just
local SomePlayer = Players.LearningBasic
?
The client should not be able to send arguments over remotes that give them an advantage, simple as that.
Also, itâs important to not manage your UIâs from a server script. Itâs better to use remotes [when needed, such as shops,quests,etc].
How would you know who the player is. That is what LocalPlayer is and the reason why I place my server scripts in StarterGui.
playeradded will do the trick
EDIT: Sorry if itâs âannoyingâ itâs just the answer is right thereâŚ?
Going back to the example you were already given:
local Players = game:GetService("Players") -- The players service.
Players.PlayerAdded:Connect(function(Player) -- This passes the player instance as "Player"
-- Do whatever you need to do with the player here instead of doing FindFirstAncestorOfClass('Player')
end)
It could be in a loop? Maybe it could be saved as a string? I didnât give you code that you were supposed to use, it was an example.
local PlayersList = {}
for _, Player in pairs(Players:GetPlayers()) do
--Boom, you can now refer to a player.
table.insert(PlayersList, Player.Name)
end
for _, PlayerName in pairs(PlayerList) do
--You can refer to a player by doing this as well
local Player = Players[PlayerName]
end
Or, with remotes:
RemoteEvent.OnServerEvent:Connect(function(Player)
--Player is sent automatically as the first argument
--As far as I know, exploiters can't spoof the first argument
--As I explained before, maybe the server checks the IP and infers the player through that
end)
Yes, thatâs actually a good substitute. Honestly Iâm just thinking to much about it.
Itâs not a âsubsituteâ its the first thing you shouldâve thought about, Itâs a ROBLOX service - And itâs way less hacky than what you are trying to do, Keeps everything clean because itâs a singular script, Therefore i recommend you just try playeradded and when it doesnât work how you want THEN you can try a diffrent method. please i just want this discussion of odd methods to end
I appreciate the help, that will be what I am adjusting to. Thank you