✓ Accepted answer
When debugging code it is good to find out the value:-
local part = script.Parent
local function Clicked(playerWhoClicked)
print(part.Transparency)
if part.Transparency == 0.9 then
part.Transparency = 0
else
part.Transparency = .9
end
end
script.Parent.ClickDetector.MouseClick:connect(Clicked)
Output:-
0.89999997615814
The problem
Floating points. As sown in the example the code will never be able to compare to 0.9
The simplest solution
Just invert your logic
local part = script.Parent
local function Clicked(playerWhoClicked)
if part.Transparency == 0 then
part.Transparency = .9
else
part.Transparency = 0
end
end
script.Parent.ClickDetector.MouseClick:connect(Clicked)
Hope this helps.
2 comments
Have you checked if the window's transparency is actually 0.9?
Yes I have. In fact I was going to use this to all my windows which are all .9