Exploiters can remove any descendant of their character and it will replicate, which is an easy way of just breaking stuff in the game in my scenario.
Is there any way to stop this without using DescendantRemoved and somehow letting it figure out if it can be destroyed or not? If not what is the best way of letting the script know what can and can’t be destroyed?
This is how I’ve sorted my values and such, if DescendantRemoved method is bad, what is the best way of storing them? NPCs also follow the same setup.
First of all,Storing values in the Character is not a good idea. for second you can use DescendantRemoving (For some reason DevHub article is broken) and clone the Removing part back to it’s original place (Don’t forget to have a pass-trough to when the player dies and when you actually want to remove parts)
The client can edit on the client anything and you can’t really do too much about it. Having a event checking the client on the server wouldn’t be the best way either. It might just be a good idea to leave it on the client because think of it this way: if they remove that folder you have, then they are ruining their own gameplay. Sadly, there is no point of putting a LocalScript that checks if the folder is there. Nothing is stopping the client from deleting that LocalScript. If you have one LocalScript that handles most of what the client does (e.g. remote events etc) you could add the code checking if the player has those values there, causing the game to be unplayable if they delete that script.
I mean to begin with exploiters are horrible - if they have stuff on client side which they can delete they will try and do it.
The thing about deletion is that you need a relative “third party” (not really a third party) overviewing it e.g. a script which is within the ServerScriptService.
I’m about to try this myself so I guess we’ll both see if it works: You could set a :WaitForChild() with a time loop of around 10 seconds for example. If it can’t find one of the required children (you will make a list of the required stuff) such as body parts when they should have them the game can remove them. You can also ping scripts technically by setting an invoke and direct it specifically at any client and then it replies true (a custom message would be better as to stop replication).
I wouldn’t store values in the character themselves, you’d just be better calling it from a table in a script or holding it within a local script else your just asking people to change your variables.
Addendum 1:
Just updating on what @Crystalflxme said in their answer. The client can’t edit everything but they can edit a large number of crucial things such as the replicated storage and the workspace (client side) and their own characters etc. They can’t see whats in serverstorage / serverscriptservice nor can they edit them as they are not in scope.
I’ll find a way of storing those values elsewhere such as replicated storage before I make more progress to the game. The client can delete if it they want that’s not much of a problem to me it’s just it being removed server sided. Other more important values e.g things that players shouldn’t be able to view at all will go in server storage.
To my knowledge the only thing the client is able to change and it’ll replicate between client and server is everything under their character:
Humanoid, HumanoidRootPart etc