So, here is a detailed list of what happens
-CLOSED have the ClickDetectors -OPEN and CLOSED have the scripts -When CLOSED is clicked, it's CD's are removed and the OPEN have a ClickDetector Cloned -When OPEN is clicked, it's CD's are removed and the CLOSED have a ClickDetector Cloned.
OPEN:
local OPEN = script.Parent.Parent.OPEN local CLOSED = script.Parent.Parent.CLOSED function onClick() OPEN.Transparency = 1 OPEN.CanCollide = false OPEN.ClickDetector:Destroy() wait(0.5) CLOSED.Transparency = 0 CLOSED.CanCollide = true CLOSED:Clone(game.Lighting.ClickDetector) end script.Parent.ClickDetector.MouseClick:connect(onClick)
CLOSED:
local OPEN = script.Parent.Parent.OPEN local CLOSED = script.Parent.Parent.CLOSED function onClick() CLOSED.Transparency = 1 CLOSED.CanCollide = false CLOSED.ClickDetector:Destroy() wait(0.5) OPENTransparency = 0 OPEN.CanCollide = true OPEN:Clone(game.Lighting.ClickDetector) end script.Parent.ClickDetector.MouseClick:connect(onClick)
You seem no not be using the clone command correctly. Take your line:
OPEN:Clone(game.Lighting.ClickDetector)
This isn't correct. Try,
OPEN:Clone().Parent=game.Lighting.ClickDetector
Now simply fix your remaining code up and we get:
OPEN:
local OPEN = script.Parent.Parent.OPEN local CLOSED = script.Parent.Parent.CLOSED script.Parent.ClickDetector.MouseClick:connect(function()) OPEN.Transparency = 1 OPEN.CanCollide = false OPEN.ClickDetector:Destroy() wait(0.5) CLOSED.Transparency = 0 CLOSED.CanCollide = true CLOSED:Clone().Parent=game.Lighting.ClickDetector end)
CLOSED:
local OPEN = script.Parent.Parent.OPEN local CLOSED = script.Parent.Parent.CLOSED script.Parent.ClickDetector.MouseClick:connect(function()) CLOSED.Transparency = 1 CLOSED.CanCollide = false CLOSED.ClickDetector:Destroy() wait(0.5) OPENTransparency = 0 OPEN.CanCollide = true OPEN:Clone().Parent=game.Lighting.ClickDetector end)
If this helped, please accept and upvote!
~Chem