This is my first post on the DevForum, so please bear with me if this doesn’t meet the requirements for the forum.
I gave my unexperienced friend access to my studio so I could try to explain how building works. Without my knowledge, he selected every part in the game and duplicated them. Because I was unaware, I continued to develop my game. I’ve made substantial progress and have only now realized that 2/3 of the game has duplicate parts.
I’ve tried to use a plug-in that "removes all duplicate parts. --Outdated, deleted random parts
I’ve tried using public scripts that people have created and inserting them into the command bar. Still deleted random parts. And, again, this post was outdated.
It’s frustrating having to delete duplicates constantly as I’m building, so I’m curious if there’s any quick script or plug-in that someone would generously provide me that would scan my Workspace and delete all parts, meshes, etc, that are copied in the same exact position and orientation without deleting the original.
You could iterate through every part of workspace, and save each thing you come across in a table (properties and all).
Then, if you find one that already shows up in the table, then you can delete it!
for _,v in pairs(game.Workspace:GetDescendants()) do
if v:IsA("BasePart") and not v:IsA("Terrain") then
for _,vv in pairs(v:GetTouchingParts()) do
if v.CFrame == vv.CFrame then
vv:Destroy()
end
end
end
end
Save a backup in-case, of course. This will go through everything, get the things it’s touching, and if it’s touching something with the same CFrame as itself it will delete it. You can extend the similarities to check first if you’d like, I just used CFrame as that encompasses location + rotation
There is a chance your code and error while running this. I recommend adding an “else” in case there is somehow an error stating some sort of CFrame cannot be accessed. I got an error using the original code and it kept repeating so it didn’t do its job. Try running this in your command line instead:
for _,v in pairs(workspace:GetDescendants()) do
if v:IsA("BasePart") and not v:IsA("Terrain") then
for _,vv in pairs(v:GetTouchingParts()) do
if v.CFrame == vv.CFrame then
vv:Destroy()
else
// No need to add anything here, unless you want it to print something
end
end
end
end