How to code a texture changing UI

I need help with coding a GUI that when you click on it, the texture of an object changes. For example, If you click the GUI, the texture on the part gets removed, but if you click back the original texture that you’ve put in the part comes back.

you don’t have a script, and you didn’t explain it completely, do you want the texture to be local, or do you want it to be seen by everyone

I can offer you a script that “hides” the texture of the Part using ClickDetector. I can’t check the script but I hope it works. Create a ClickDetector and place it under Part. Then create a Script for ClickDetector. Instead of YourTexture and YourPart, add your own Part and texture.

Local YourTexture  = game.Workspace.YourPart.YourTexture
Local ClickDetector = script.Parent

ClickDetector.MouseButton1Click:Connect(function() 
if YourTexture.Transparency = 0 then         
YourTexture.Transparency = 1 
elseif YourTexture.Transparency = 1 then 
YourText.Transparency = 0 
end) 

If you are interested in more information about ClickDetector and Texture features, I will leave links.

Texture

ClickDetector

1 Like

– Put the parts you want to change the material of in a folder named “Parts” or whatever you want it to be.
– Put this script in the button of the screengui

script.Parent.MouseButton1Click:Connect(function()
for i,v in pairs(game.Workspace.Parts:GetDescendants()) do
if v:IsA(“Part”) then
v.Material = “Plastic”
end
end
end)

1 Like