--Right	0	
--Top	1	
--Back	2	
--Left	3	
--Bottom	4	
--Front	5

v = 1	
s = 0
osi = 0
print(s)
if s == 0 or s == 3 then
	osi = p.Size.x - 1
elseif s == 1 or s == 4 then
	osi = p.Size.y - 1
elseif s == 2 or s == 5 then
	osi = p.Size.z - 1
end

function open()
	for i = 1, osi, v do
		local r = p:Resize(s, -v)
		if not r then
			repeat
				wait(0.1)
			until
				p:Resize(s, -v) == true
		end
		wait(0.1)
	end
end

function close()
	for i = 1, osi, v do
		local r = p:Resize(s, v)
		if not r then
			repeat
				wait(0.1)
			until
				p:Resize(s, v) == true
		end
		wait(0.1)
	end
end

script.Parent.opened.Changed:connect(function (v)
	if v then
		open()
	else
		close()
	end
end)
