--Door Script
--This script toggles the door when it is clicked.
--Unless you know what you're doing, do not modify this script.

local clickdetector = Instance.new("ClickDetector", script.Parent) --This creates a click detector for the door.
clickdetector.MouseClick:Connect(function() --This detects a click on the door.
	if script.Parent.CanCollide == true then --This checks if the door is closed.
		script.Parent.Open:Play() --This plays the open sound.
		script.Parent.Transparency = 0.25 --This causes the door to be slightly transparent.
		script.Parent.CanCollide = false --This causes the door to stop colliding.
	else --If the door is open, then the code below will run instead.
		script.Parent.Close:Play() --This plays the close sound.
		script.Parent.Transparency = 0 --This causes the door to be completely opaque.
		script.Parent.CanCollide = true --This causes the door to begin colliding.
	end
end)
