How do I make a button that changes a decals texture when clicked?

Hi! I would like to know how I would create button (or a part) that I can press that changes the texture of a decal on another part.

I have tried to use solutions on the Dev Forum, but the ones I have tried have not seemed to work.

2 Likes

What does your current state in the process look like? I can help you from there.
Can you send a few pictures of your explorer and the parts you are using?

2 Likes

Have a Part with a Decal inside it, and another Part with a ClickDetector and a Script in it. Make sure the parts are named differently, such as “DecalPart” and “Button” so that you can reference them in the script. Should look something like this:

image

This is what your script should look like:

script.Parent.ClickDetector.MouseClick:Connect(function()
	
	game.Workspace.DecalPart.Decal.Texture = "http://www.roblox.com/asset/?id=78447821" -- Change the decal Id
	
end)

I got the Texture by finding a decal in the marketplace, copying the ID, and pasting it into the Texture field inside the Decal in studio.

Result:
https://gyazo.com/72ba501ddba49e9921d8f8fd44c970cb

Hope this helps!

4 Likes

When I clicked the button, instead of changing it to the decal I had put in, it went blank. I tested the decal to make sure it worked on another part, and it showed up.

Do you know how I could fix this?

Are you using the same Script Jax posted?

1 Like

Yes. I think it may have to do with the decal I used, since I tried using other ones and it worked.

If the decal shows something in the workspace before testing, then just make sure that you put the right Image Id into the script.

I’m not sure why it wasn’t showing up, but now it works! Thank you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.