ClickDetector - Part Transparency

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    When you click once, the part appears, when you click again, the part dissapears.

  2. What is the issue? Include screenshots / videos if possible!
    I cannot make it so when you click once, it appears, when you click again, it dissapears.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried changing the first “end)” around but couldn’t figure that out.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

MasterKey = script.Parent
Click = workspace.MasterKeyInsert.ClickDetector

Click.MouseClick:Connect(function()
    MasterKey.Transparency = 0
end)
    Click.MouseClick:Connect(function()
        MasterKey.Transparency = 1
end) 

This is probably really simple, but then again we all make mistakes.

Devfourm Assistance - YouTube

you should use if iterator, example in this case:

Click.MouseClick:Connect(function()
if MasterKey.Transparency == 0 then
MasterKey.Transparency=1
else
MasterKey.Transparency=0
end
end)

oh and one more thing this is a switcher, meaning it will reappear and dissappear forever as you click on the part until you remove it from workspace, folder etc.

Thank you, seems it was so simple & I thought to do it but it seems I went wrong, appreciate it!

you could do the same thing with a boolean too to be sure that no external factors change its transparency, for example:

local transparent = false

Click.MouseClick:Connect(function()
if transparent then
MasterKey.Transparency = 0
transparent = false
else
MasterKey.Transparency = 1
transparent = true
end
end)

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