I have a simple optimization script, that makes every part with a material in the game become Plastic.
The code DOESN’T work, and it errors:
The current thread cannot access ‘StreamingService’ (lacking capability Assistant) - Client
I have found no solution for this error so far. I hope someone can help me.
For anyone wondering, this is the code
local TimesClicked = 1
script.Parent.MouseButton1Click:Connect(function(Optimize)
if TimesClicked== 1 then
local TableForPreviousMaterials = {}
for i, children in pairs(game:GetDescendants())do
if children.ClassName == "MeshPart" or children.ClassName == "BasePart" or children.ClassName == "UnionOperation" then
TableForPreviousMaterials [children] = children.Material
end
end
function UndoOptimization(material)
for part, StoredMaterial in pairs(TableForPreviousMaterials) do
part.Material = material or StoredMaterial
end
end
UndoOptimization(Enum.Material.Plastic)
TimesClicked= 2
if TimesClicked== 2 then
UndoOptimization(nil)
TimesClicked= 1
end
end
end)
local numero = 1
script.Parent.MouseButton1Click:Connect(function(goofy)
if numero == 1 then
local materials = {}
for i, children in pairs(game:GetDescendants())do
if children.ClassName == "MeshPart" or children.ClassName == "BasePart" or children.ClassName == "UnionOperation" then
materials[children] = children.Material
end
end
function UndoOptimization(material)
for part, savedMaterial in pairs(materials) do
part.Material = material or savedMaterial
end
end
UndoOptimization(Enum.Material.Plastic)
numero = 2
if numero == 2 then
UndoOptimization(nil)
numero = 1
end
end
end)
local numero = 1
script.Parent.MouseButton1Click:Connect(function(goofy)
if numero == 1 then
local materials = {}
for i, children in pairs(game.Workspace:GetDescendants())do
if children.ClassName == "MeshPart" or children.ClassName == "BasePart" or children.ClassName == "UnionOperation" then
materials[children] = children.Material
end
end
function UndoOptimization(material)
for part, savedMaterial in pairs(materials) do
part.Material = material or savedMaterial
end
end
UndoOptimization(Enum.Material.Plastic)
numero = 2
if numero == 2 then
UndoOptimization(nil)
numero = 1
end
end
end)