-- our resources
local detector = script.Parent
local model = game.Workspace.Door1
-- clone and state
local clone = model:Clone()
local state = false
-- function to make our door
function makeDoor()
local inst = clone:Clone()
inst.Parent = Workspace
end
-- remove the model and replace it to resolve it to a variable
model:remove()
local inst = makeDoor()
-- setup hook for mouseclick.
detector.MouseClick:connect(function(plr)
if(state)then
state = false
inst = makeDoor()
else
state = true
inst:remove()
end
end) |