My transparency script doesn't work

It doesn’t work and it didn’t make any warnings or errors

change it and use an elseif/else instead of two if statements.

Now I created this:

trasparent = false
while wait() do
	if script.Parent.ClickDetector.MouseClick and trasparent == false then
		trasparent = true
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
	end
	if script.Parent.ClickDetector.MouseClick and trasparent == true then
		trasparent = false
		script.Parent.Transparency = 0
		script.Parent.CanCollide = true
	end
end

change it to this

trasparent = false
while wait() do
	if script.Parent.ClickDetector.MouseClick and trasparent == false then
		trasparent = true
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
	else script.Parent.ClickDetector.MouseClick and trasparent == true then
		trasparent = false
		script.Parent.Transparency = 0
		script.Parent.CanCollide = true
	end
end

edit: dont use that

My script output this:

go back to this script and put else instead of another if.

edit: also delete the second “end”

elesif or else?

Random cause it wont let me text: 4934u02nfoj9jonduhf9judf9njb

use else, elseif is checking specifically for different conditions.

Now this looks like this I’m gonna try

trasparent = false
while wait() do
	if script.Parent.ClickDetector.MouseClick and trasparent == false then
		trasparent = true
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
	else
		trasparent = false
		script.Parent.Transparency = 0
		script.Parent.CanCollide = true
	end
end

so your gonna use that script instead?

It’s made transparent but it’s flickering like “1-0-1-0-1-0” in transparency I think I should use " elseif "

it wont change anything.
instead of using while wait() do
use script.Parent.ClickDetector.Mouseclick:Connect(function())

trasparent = false
script.Parent.ClickDetector.MouseClick:Connect(function()
	if trasparent == false then
		trasparent = true
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
	end
	if trasparent == true then
		trasparent = false
		script.Parent.Transparency = 0
		script.Parent.CanCollide = true
	end
end)

you still need to use else in your script.

Like this?

trasparent = false
script.Parent.ClickDetector.MouseClick:Connect(function()
	if trasparent == false then
		trasparent = true
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
	else
		trasparent = false
		script.Parent.Transparency = 0
		script.Parent.CanCollide = true
	end
end)

Yes, that should make it work.

It worked but instantly made the transparency back to “0”

check if the parts transparency is equal to 1 instead of making a variable.

I used “elseif” too and made that again