Trying to make windows become non see through when clicked. The clicker shows up and such, but nothing happens to the window.
local part = script.Parent local function Clicked(playerWhoClicked) if part.Transparency == .9 then part.Transparency = 0 else part.Transparency = .9 end end script.Parent.ClickDetector.MouseClick:connect(Clicked)
When debugging code it is good to find out the value:-
local part = script.Parent local function Clicked(playerWhoClicked) print(part.Transparency) -- simple print 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 -- logic swapped part.Transparency = .9 else part.Transparency = 0 end end script.Parent.ClickDetector.MouseClick:connect(Clicked)
Hope this helps.