How to make part non deletable

I’m making something and I need it so it cant be deleted.

I don’t know how I would do it.

I haven’t tried anything and haven’t looked on the dev fourm.

SOLVED BY TEEFUS

What do you mean by it can’t be deleted? Do you mean you don’t want to be able to delete it in studio?

Nono I mean like just not be able to be deleted anywhere.

Would locked work?

1 Like

What do you mean though by not deleted anywhere. Nothing gets deleted unless you either have a script to delete it or you delete it manually in studio.

1 Like

Locked only prevents building tools from deleting it. Scripts can still easily use the :Destroy() function to remove them. I don’t think there is a way to prevent that.

Just make sure you don’t have any scripts deleting the part.

I don’t want scripts to delete it.

Then the part will never get deleted unless you delete it yourself in studio. There’s no way to prevent a part from being deleted, the only prevention is you not deleting it yourself.

There isn’t a property preventing scripts from deleting anything. As long as you don’t have any scripts that delete a certain object, that object will never get deleted.

I’m making a game kinda like script builder so uhhh.

What exactly are you worrying about? Can you tell us this “something”?

I’m not a scripter but I have an idea. Make a script that detects if the part is destroyed. If it is, then it creates the part again? I don’t know if it’s a working idea.

You can use a connection like AncestryChanged or Part.Parent.Changed and connect a function to create another copy of the part in the same place.

Script builder type game. AAA I DONT WANNA PRESS THE HEART BUTTON BEACUSE MY MESSAGE ISN’T 30 CHARACTERS

For that you could try using a blacklist of what cannot be deleted. The naive approach would be to have a copy of scripts and such in ServerStorage, check if a certain thing in workspace doesn’t exist and if it doesn’t, replace it. I don’t recommend this approach though lol.

but what if they delete it in serverstorage

1 Like

I know what you could do. Create a table with all the objects which are blacklisted and refrain the executor from running any sort of code inside ServerScriptService or ServerStorage and keep checking if the objects in the blacklist table exist and if they don’t you could replace them with another copy.

1 Like

Since its for a script builder you can set the environment the code that you’re compiling can access. Just replace their game object with your own fake game object that can’t access ServerStorage.

You can set a function’s environment using setfenv or alternatively use getfenv and redefine variables.

Make sure to wrap all properties too, so they don’t do something hacky like workspace.Parent which might return the true game object.

2 Likes

but what if they make a module

I don’t think scripting games run full server side scripts, cause if they do then an exploiter can easily break the game.