The objects are a table,
local players = game:GetService('Players')
local localplayer = players.LocalPlayer
local char = localplayer.Character or localplayer.CharacterAdded:wait()
repeat wait() until char:WaitForChild("Head")
local togglebutton = script.Parent
local materials = true
local smoothplastic = Enum.Material.SmoothPlastic
local objects = {}
wait(4)
local function scan(object)
for i,v in pairs(object:GetDescendants()) do
if v:IsA("Part") and v.Material then
table.insert(objects, v.Material)
end
end
end
scan(game.Workspace)
togglebutton.MouseButton1Click:Connect(function()
materials = not materials
if materials then
for i, v in pairs(game.Workspace:GetDescendants()) do
if v:IsA("Part") or v:IsA("UnionOperation") and v.Material then
v.Material=objects[i]
end
end
togglebutton.Text = 'UNTOGGLE LOW GFX MODE'
else
for i, v in pairs(game.Workspace:GetDescendants()) do
if v:IsA("Part") or v:IsA("UnionOperation") then
v.Material=Enum.Material.SmoothPlastic
end
end
togglebutton.Text = 'TOGGLE LOW GFX MODE'
end
end)
I'm trying to make it so you can toggle materials, but it doesn't seem to work. Any advices? The error in the output says: 14:47:03.544 - > Invalid value for enum Material Oh yeah, extra informations, the objects part is a table {} with materials in it. But it says It's a value, how can I fix this?

3 comments
I've never seen Enum.Material used to change the material of an object. Try using v.Material = "SmoothPlastic". That should take care of the Enum Value problem
@sergeant_ranger, you can use enum to change a material, but your way works too
Here, sorry guys I provided the full script. Please help as soon as you can. Thanks!