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

How to change transparency of a Part when you click on a click detector?

Asked by 1 year ago

I need to give some context, the script is inside a button part, and the click detector is in a part called "ButtonActivate". The Button Part is called ButtonThing and Button Thing is inside a model with ButtonActivate, and the model is in a folder called Button. I want to make it so that when you click on the button activate, the ButtonThing's transparency is equal to 1, but my script doesn't work. (I'm new to scripting btw)

The script that doesn't work:

function OnClick()
    script.Parent.Transparency = 1
end

script.Parent.Parent.ButtonActivate.ClickDetector:connect(OnClick)

2 answers

Log in to vote
0
Answered by 1 year ago

The problem is that you weren't actually detecting when the player clicked on the button. Try this instead:

local clickDetector = script.Parent.Parent.ButtonActivate.ClickDetector

clickDetector.MouseClick:Connect(function()
    script.Parent.Transparency = 1
end)
1
I actually right before you sent this answer I figured out how to do it, but this one is simpler and if i want to re-write it its easier so i switched to this code. Tysm! ilovekidcity 10 — 1y
Ad
Log in to vote
0
Answered by
enes223 327 Moderation Voter
1 year ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question