Part Transparency Script

Hello!

So I made a script with a clickdetector, where when an invisible part is clicked, it becomes visible. However, I’m having trouble with how to get the part to go back to being invisible when clicked again.

local clickDetector = script.Parent:WaitForChild("ClickDetector")
local door = game.Workspace["door"]

clickDetector.MouseClick:Connect(function()
	door.Transparency = 0
	task.wait(0.1)
end)

Try this

local ClickDetector = script.Parent:WaitForChild("ClickDetector")
local Door = workspace.door

local Open = false

ClickDetector.MouseClick:Connect(function()
	if Open == false then
		Open = true
		Door.Transparency = 1
	else
		Open = false
		Door.Transparency = 0
	end
end)
1 Like

It worked! I see what to do now, I appreciate it!

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