So, I am working on this low graphics button that disabled all materials and changes them to the “Smooth Plastic” material. There is one problem though, I am getting an error of Invalid value for enum Material. I cannot figure out how to fix this error, any ideas? I will provide my code below so that it is easier for you to assist me with my issue.
Code
local Enabled = false
local Button = script.Parent
for i, part in pairs(workspace:GetDescendants()) do
if part:IsA("BasePart") then
table.insert(Materials, i, part.Material)
end
end
Button.MouseButton1Click:Connect(function()
for _, part in pairs(workspace:GetDescendants()) do
if part:IsA("BasePart") and Enabled == false then
Enabled = true
Button.Text = "LOW"
part.Material = Enum.Material.Plastic
elseif Enabled == true then
for i, part in pairs(workspace:GetDescendants()) do
if part:IsA("BasePart") then
Enabled = false
Button.Text = "HIGH"
part.Material = Materials[i]
end
end
end
end
end)