Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a button that when clicked changes the Transparency of a decal?

Asked by 4 years ago

If possible im looking for a part that serves as a button,when clicked with a mouse a decal on a part should turn from having transparency 1 to 0, and if clicked twice it should come back to normal. I have reserched on youtube and found out how to do this with a part but the decal on the part does not change transparency with it. Could any one help me with this?

2 answers

Log in to vote
1
Answered by
pwx 1581 Moderation Voter
4 years ago

You can try something like this:

local Button = script.Parent -- change this to where the button is located
local Decal = script.Parent.Parent.Decal -- change this to where the decal is located

Button.MouseButton1Down:Connect(function()
    if Decal.Transparency == 1 then
        Decal.Transparency = 0
    elseif Decal.Transparency == 0 then
        Decal.Transparency = 1
    end
end)
0
Sory but could you explain if im duposed to delete the last parent and decal and put the model of the button and the part of the decal in there or if i just put them in front or if i should put the name of the button and not the model. If yo could explain i ould be tankfull and sory for spending your time mastermind035 2 — 4y
0
Put the script inside the button. Then locate the decal by using .Parent until you reach the correct, well- Parent. pwx 1581 — 4y
0
If you're still confused, add my discord and I'll help you out. Josh K#2740 pwx 1581 — 4y
0
Tanks it worked, it finaly worked thanks so much mastermind035 2 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

Decals don't change transparency with their brick. You have to change the transparency of the decal itself. Just have the path point to the decal's transparency property.

Answer this question