My transparency script doesn't work

Yes it’s making the part transparent for a millisecond but It turns back to 0

can you show me the current script?

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

instead of using the transparent variable just check if script.parent.transparency = 1

Like this?

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

yes like that. That should work.

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

Two of them doesn’t work I don’t know why is like that because I made a lot of buttons in the past using “ProximityPrompt” or “ClickDetector” but now I really don’t know what is happening.

What does it do when you click it?

It makes transparent and closes the collision.

So the script is working for you?

Art of math:

local part = script.Parent
part.ProximityPrompt.Triggered:Connect(function()
	part.Transparency = 1-part.Transparency
end)

This script I made in the first but doesn’t work on proximity prompts I think cause it worked on click detector now

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

thanks for yall guys i dont know what happend and i think i cant know

you can delete that script then. Any script that was supposed to change the hoods transparency should be deleted except for the one your using right now.

1 Like

actually don’t need it cause people can go to solution

Oh ok. I hope your journey learning scripting will help you gain the knowledge to script an entire game at some point, good luck.

1 Like

Thank you for all support and here is my game:
(Untitled Car Game - Roblox)

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