I have a settings menu in my game that has different settings for the player to turn on and off to their preferences.
I want to have a setting that allows you to turn on and off materials/textures (or just set all of them to plastic). How could I got about doing this from a local script? if anyone can help I would appreciate it!
You could do something where the server sends the textures to the client so the client can replicate it. Or you could find a way to save the textures of every part in the background like in a script or via attributes. But I think the first option is probably the easiest
local button = script.Parent
local materialsVisible = true
function hideMaterials(gameParts)
local oldMaterial = Instance.new("StringValue")
oldMaterial.Value = gameParts.Material.Name
oldMaterial.Name = "OldMaterial"
oldMaterial.Parent = gameParts
gameParts.Material = Enum.Material.SmoothPlastic
end
function showMaterials(gameParts)
local oldMaterial = gameParts:FindFirstChild("OldMaterial")
gameParts.Material = Enum.Material[oldMaterial.Value]
oldMaterial:Destroy()
end
button.MouseButton1Click:Connect(function()
if materialsVisible == true then
materialsVisible = false
for i, gameParts in pairs(workspace:GetDescendants()) do
if gameParts:IsA("BasePart") then
hideMaterials(gameParts)
end
end
else
materialsVisible = true
for i, gameParts in pairs(workspace:GetDescendants()) do
if gameParts:IsA("BasePart") then
showMaterials(gameParts)
end
end
end
end)