Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

2 answers

✓ Accepted answer

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 comment

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!

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

This discussion is preserved as it was. New answers, comments, and votes are closed.