Anti-Exploit / Updating code improving

How can I improve this code? I wanna make it the best I can. It’s half anti-exploit half updating player values. It seems to be good, but I wanna make sure I can make it the best I can.

while wait(10) do
	local ServerStorage = game:GetService("ServerStorage")
	local ServerFolders = ServerStorage.PlayerService
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local PlayerService_ClientService = ReplicatedStorage.PlayerService.ClientService
	
	local ServerFoldersChildren = ServerFolders:GetChildren()
	local ClientFoldersChildren = PlayerService_ClientService:GetChildren()
	
	for index, value in pairs(ServerFoldersChildren) do
		PlayerService_ClientService:WaitForChild(tostring(value)):Destroy()
		value:Clone().Parent = PlayerService_ClientService
	end
end
2 Likes

This code seems kind of redundant. You’re cloning values from ServerStorage to ReplicatedStorage for no reason, since clients already can’t edit the contents in ReplicatedStorage.

Is there a specific reason to need this code at all?

3 Likes

The client needs a copy of the folders however if it was in replicated storage, no copy is there so any person can simply change it and gain access to many hidden things. If there’s a server copy, you can frequently change it. I’m not to sure, but the client side isn’t a main, it’s more of a Server-Client thing, but I can simply just transfer them from remote events etc

Your current approach suffers from the same issue you’re trying to solve: the client locally changing information. Just relying on the server reading the information out of ReplicatedStorage solves your issue, as stated earlier if the client makes changes there it won’t be seen on the server.

It’s preferable you just remove code like this and make use of the replication rules Roblox has in place by just storing the folder in ReplicatedStorage to begin with.

3 Likes

True, but then local scripts won’t have the same information as the server because someone can simply change it and bypass the wall?

However, I could just do what I said before and pass information from the Server to the Client when it’s needed.

You don’t need to do any of this you can just put the values in Replicated Storage and let both the clients and the server read from it. If a client changes something it will only change for them and not affect any of the other clients.

I know. But keep in mind the values inside the folder determine your rank etc and whether you have access to things or not. If the client gives themself the value, they get things they aren’t meant to.

Are you giving them items on the client or on the server? If the client changes their rank locally the server won’t be able to see it. You should check their rank on the server and then give them the items they should be getting from there.

That’s what i already do. If the player’s UserId matches one from a UserId table, the value “UserId” gets set to true. Same with group, if their rank is matches to a table, they get “GroupRank” Value set to true.

So what would happen if an exploiter changed their GroupRank value to true?
Edit: If the checks are done on the server it should have no affect so you can safely store the values in ReplicatedStorage and you don’t need the script you posted

Every 10 seconds, as the code I posted does, it deletes the Client Replicated one and clones the Server one, and puts it back in the client folder.

But why? If the checks are on the server why does it matter if the client changes the value locally? It will never show up on the server anyway

There are LocalScripts which would need the Client folders to do things etc doors or GUIs

What if an exploiter just does this.

game.ReplicatedStorage.PlayerService.ClientService.ChildAdded:Connect(function(child)
   child.Value = true
end)

This would automatically set any copied values to true every time you clone them. Also if it’s handled in a local script an exploiter could just delete the door anyway like this.

workspace.Door:Destroy()

All these checks you’re doing are completely unnecessary and can be bypassed easily. It’s better to just do the important checks on the server and let exploiters go through the doors if they want because they could just noclip or teleport in anyway.

3 Likes