When I code, I copy my scripts usually but when there’s an issue in all of them, I find tiring replacing them one by one, so I made this script:
print("Replacing...")
local ReplaceWith = Instance --Instance you want "the other instances" to be replaced with.
local Replace = "Lorem" --"the other instances", the script determines if the instances are unwanted using it's name.
local ReplaceIn = Instance --Instance where the script searches for "the other instances"
if ReplaceIn == nil then
print("An error has occured, One of the values you set is nil.")
wait(1)
print("REPLACE!")
else
print("Preparing for replacing...")
local AmountReplacements = 0
for i = 1, table.maxn(ReplaceIn:GetDescendants()) do
task.wait()
local Object = table.unpack(ReplaceIn:GetDescendants(), i)
if Object == nil then elseif Object.Name == Replace then
AmountReplacements += 1
end
end
local j = (table.maxn(ReplaceWith:GetDescendants())*AmountReplacements)
for maini = 1, table.maxn(ReplaceIn:GetDescendants())+j do
task.wait()
print("Replacing... (Checking Object "..maini.."/"..table.maxn(ReplaceIn:GetDescendants())+j..")")
local Object = table.unpack(ReplaceIn:GetDescendants(), maini)
if Object == nil then
print("An error has occured, Object "..maini.." does not exist. Skipping the object...")
else
local parents = string.split(Object:GetFullName(), ".")
if Object.Name == Replace then
local ObjectParent = Object.Parent
Object:Destroy()
local NewObject = ReplaceWith:Clone()
if NewObject == nil then
print("An error has occured, Attempt to index nil with object "..maini..". Skipping the object...")
else
NewObject.Parent = ObjectParent
end
end
end
end
print("Finished!")
wait(1)
print("REPLACE!")
end
What this script does is, that it replaces all faulty/unwanted instances with a selected instance up to one, which for some reason you have to delete yourself.
Video:
WARNING!!!
Before proceeding, make a backup of your expierience, otherwise I am not responsible for actions this script does/did.