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

Why isn't this brick turning invisible?

Asked by 10 years ago

I have a script. When you click it (yes i do have a click detector), it is supposed to turn invisible. Pretty simple script, but it isn't working

here is the script

function click()
    wait(0.5)
    script.Parent.Transparency = 1
end

script.Parent.MouseButton1Down:connect(click)

Thank you

2 answers

Log in to vote
3
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Your problem is the fact that you're using the wrong event.

MouseButton1Down is used for GUIs. However, you want to make a Part clickable, so you need a different event.

What you're looking for is the MouseClick event of ClickDetectors.

Remember, a Part itself has no events to record mouse input. Parts are entirely dependent on their ClickDetectors.

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

script.Parent.ClickDetector.MouseClick:connect(click)
0
Thank you, I am used to doing GUI's yogipanda123 120 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

If you're putting the script in the part, you're trying to bind the click event to the part.

script.Parent.ClickDetector.MouseButton1Down:connect(click)

If you're putting the script in the detector, you're trying to make the detector transparent.

script.Parent.Parent.Transparency = 1

Answer this question