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!