[1] How to mass-remove malicious scripts or objects

Hello! After some recent troubles with backdoors and having my game filled with malicious scripts, I thought it’d be helpful to show you guys how I mass removed these objects from my game.

Note: This tutorial will require a basic or intermediate level of how looping through objects (specifically services) work!

So the first thing we want to do is create a script. This is a temporary script to allow us to write our code without getting confused.

Now, create a folder called “Caught” in Workspace. Don’t mind this for now.

Now, we have to loop through the descendants of the service we are cleaning. So lets use workspace as an example.

for i,v in ipairs(workspace:GetDescendants()) do

end

Remember, GetDescendants() doesn’t take any parameters, so we’ll have to check for the name in the if statements. Lets say our malicious script name is called “HaxScript”. We need to first check for if our malicious object is a script.

for i,v in ipairs(workspace:GetDescendants()) do 
  if v:IsA("Script") and v.Name == "HaxScript" then -- leave out "v:IsA("Script") if there are multiple malicious objects named the same thing like Welds or Fires!"
  
   end
end

Great, we’ve successfully looped through the workspace for a specific object. Now we need to actually parent the offending objects.

for i,v in ipairs(workspace:GetDescendants()) do 
  if v:IsA("Script") and v.Name == "HaxScript" then 
       v.Parent = workspace.Caught 
   end
end

You see here, we parented our Caught scripts to the folder that we made in workspace! We only created this folder to check and make sure we are deleting the correct things. We don’t want to delete any scripts that we worked too hard to perfect! Once you’ve confirmed that these are the malicious scripts, right click on the folder and hit delete! Boom, you’re done!

However, if you’re feeling a bit bold, there is a way to immediately delete the script(s).

for i,v in ipairs(workspace:GetDescendants()) do 
  if v:IsA("Script") and v.Name == "HaxScript" then 
       v:Destroy()
   end
end

There! We’ve successfully deleted the scripts without confirmation. Let’s hope we didnt delete any important ones!

You’re probably wondering how you would do this in studio. Simply copy and paste this code into the Command Bar

This will run the code in studio for you, make sure to also check the Output for any errors you may receive.

I hope you enjoyed/learned something new from this tutorial. Please do note that this is my way of removing backdoors or malicious objects from my game. This is my first tutorial aswell.

Let me know what you think, good luck scripting!

8 Likes

It’s an example lol his point is that you put in whatever name is the issue

1 Like

I’m not sure how this was relevant to the tutorial I have shown you. I recently had a script named “zacksisk” in my game. Simply change the name string to “zacksisk”

1 Like

I mean personally what I do is just type in script in workspace then scroll through the list of scripts looking for anything suspicious. Haven’t needed to do this in a while now ever since I stopped using free models for a replacement for builds

1 Like

Would this work even if the “malicious object” is under a model/another parent and not directly a child of the workspace?

1 Like

Yes it would! :GetDescendants() gets the descendants of a defined object. So this will loop through everything that is in the Workspace!

2 Likes

That’s true, but when you receive commissioned maps filled with malicious scripts, it’s a pain trying to locate all the scripts and delete them all. You can simply run the code to parent the scripts to a confirmation folder before deleting them. Then you select the folder and delete it.

3 Likes

Great! This would be helpful for a lot of people, couple of my friends have their places infected, will be sure to send them this article!

2 Likes

What I usually do in a free model if I’m just looking through the catalog cause I’m bored is:

for _,item in pairs(model:GetDescendants()) do

if item:IsA("Script") then

print(item:GetFullName)
end 
end

Good tutorial though.

1 Like