How to make a GUI button that makes every objects textures into plastic

hi so I’m trying to make a GUI button that makes every object’s textures into plastic is there a way to do this?

1 Like

sure.

Button.MouseButton1Down:connect(function()
     for i,v in pairs(PATH_TO_WHERE_THE_OBJECTS_ARE:GetDescendants()) do -- or you can just do workspace and it will do everything thats in workspace
           if v:IsA('BasePart') then
               v.Material = Enum.Material.Plastic
           end
     end
end)
2 Likes

thank you! but I have one question if that’s ok, how do i revert them back?

You can always add a string value to the object and set the string value’s value as the original material. And afterwards, you can loop through the stuff again, then get the object’s string value’s value and change it back to the original material.

2 Likes

so to revert it back, just add a new instance to it with the previous material as a value. and when you want to revert it, just get that material from that instance and implement to the basepart.

something like.

local toggle = false
Button.MouseButton1Down:connect(function()
toggle = not toggle
if toggle then
     for i,v in pairs(PATH_TO_WHERE_THE_OBJECTS_ARE:GetDescendants()) do -- or you can just do workspace and it will do everything thats in workspace
           if v:IsA('BasePart') then
               local oldmaterial = Instance.new('StringValue', v)
               oldmaterial.Value = v.Material
               oldmaterial.Name = "OldValue"
               v.Material = Enum.Material.Plastic
           end
     end
else
     for i,v in pairs(PATH_TO_WHERE_THE_OBJECTS_ARE:GetDescendants()) do -- or you can just do workspace and it will do everything thats in workspace
           if v:IsA('BasePart') then
               v.Material = v.OldValue.Value
           end
     end
end
end)
1 Like

that’s cool! thanks you for helping me