How to detect if a script got deleted in studio?

Hey there!

  1. What do you want to achieve?
    What i want is that when a player removes a script in studio. A different script will detect it when entering play mode and it’ll do a function.
  2. What is the issue?
    I have tried creating some but it keeps failing.
  3. What solutions have you tried so far?
    I have searched on the web, such as; YouTube, DevForum, DevHub, and even asked people. But they couldn’t really helped me.

Thank you!

2 Likes

You can do something like:

scriptsfolder.ChildRemoved:Connect(function(instance)
    if instance:IsA("Script") then
        -- do stuff
    end
end)

(woops i didnt read you wanted it in studio, i dont think you can run scripts in studio like that, only command bar)

3 Likes

What exactly is the use case here? The player could delete the script performing this check and you’d be back to square one.

By “studio” do you mean while the game is running, or when it is not?


So the thing is this, the script “AnimationsHandler” is a whitelist, this is the script:

local UserID = 0 -- Put ID in here

if	 game.CreatorId == UserID then
	print("Correct Owner")
elseif game.CreatorId ~= UserID then
	script.Parent.Parent.Parent:Destroy()
end

You can easely remove the script to bypass the whitelist. And i don’t want that. I want it so if you delete it. Somewhere in a different script the same function will do when the script is deleted. (If the owner isn’t equal to the UserID)

So “Script” in the BR.Main Group should do that task.

I hope this will do.

1 Like

If your code is open for download, there is no way to protect its source.

Any checks you add can be disabled/deleted.

If an exploiter tries to delete a Script that’s visible to them(not a LocalScript) it wont apply any real chances on the server. Also the exploiter can write code to keep script.Parent.Parent.Parent in game for their own client anyway. So you may need to find a solution to that instead.

1 Like

I want to obfuscate the script when it’s fully done. So that’s why it’s still open.

Even if client deletes a script, the server won’t detect it, it doesn’t matter if you put a check on the server if their scripts are deleted, because changes from player client doesn’t replicate to the server, the server will still see the deleted existance.

So it’s basically impossible? Or is/might (be) there a solution for that?

Sanity checks, or you could put the delete check in a vital local script (yes, it can detect if other local scripts are deleted because it’s local, which means it’ll replicate) which is required for the game to work, which means if they delete the script in attempt to remove the anti cheat, it’ll break their side of the game. (i dont really use this, i dont know if it’ll work for your game)

Simply move all the whitelist check scripts to ServerScriptService so the client won’t be able to access it.

You can make a plugin that will detect if something deletes:

game.DescendantRemoving:Connect(function(inst)
	if inst:IsA("Script") then
		source = inst.Source
		print(source)
	end
end)

to import this as plugin, you need to select script and click ‘Save as local plugin’

1 Like

It wouldn’t work because client changes are not replicated to server, only to client so only local scripts can see client changes

They aren’t, so the best way to do this is to handle all the cars whitelist checks with 1 script, that’s stored in ServerScriptService. The client doesn’t have access to ServerScriptService meaning that they won’t be able to remove the script.

you dont get what i mean, i mean because literally the script would still see the scripts as existant even if the client removes them because client changes does not replicate to server, so the serverscript wouldnt know if script got deleted from client so its pointless

I do understand what you are saying. Sorry I was going based on some image that was up above the forum.

1 Like

Create a script with this in it:

while wait(5) do
   if workspace:FindFirstChild("ModelName"):FindFirstChild("ScriptName") == nil then --etc just go to the script
      --do what you want if the script isn't there
   end
end

if I’m correct, this is what you want?

1 Like

You want to detect if script deletes in game or in studio? If in studio,plugin will work.

I know but op is looking for client deleted scripts

In simple terms, you can’t fully stop this. However, you can make the exploiter’s time harder by checking if scripts are being deleted inside a very important script on the client so if they do delete it they will delete those other functions.