local j=script.Parent local f=j.DrawerModel.Drawer local a=script.bool.Value function onClicked(m)if a==true then a=false f.ClickDetector.MaxActivationDistance=0 f.Sound:Play()for f=1,20,1 do j:SetPrimaryPartCFrame((j.PrimaryPart.CFrame*CFrame.new(0,0,-0.1))*CFrame.fromEulerAnglesXYZ(0,0,0))wait(.05)end a=false f.ClickDetector.MaxActivationDistance=5 elseif a==false then a=true f.ClickDetector.MaxActivationDistance=0 f.Sound:Play()for f=1,20,1 do j:SetPrimaryPartCFrame((j.PrimaryPart.CFrame*CFrame.new(0,0,.1))*CFrame.fromEulerAnglesXYZ(0,0,0))wait(.05)end a=true f.ClickDetector.MaxActivationDistance=5 end end f.ClickDetector.MouseClick:connect(onClicked)
--Defining the parts of the shelf
local sp = script.Parent
local drawer = sp.DrawerModel.Drawer
local val = script.bool.Value
function onClicked(clicked)
	if val == true then
		val = false
		drawer.ClickDetector.MaxActivationDistance = 0
		drawer.Sound:Play()
		for loop = 1, 20 do
			sp:SetPrimaryPartCFrame(sp.PrimaryPart.CFrame * CFrame.new(0, 0, -0.1) * CFrame.fromEulerAnglesXYZ(0, 0, 0))
			wait(0.05)
		end
		val = false
		drawer.ClickDetector.MaxActivationDistance = 5
	elseif val == false then
		val = true
		drawer.ClickDetector.MaxActivationDistance = 0
		drawer.Sound:Play()
		for loop = 1, 20 do
			sp:SetPrimaryPartCFrame(sp.PrimaryPart.CFrame * CFrame.new(0, 0, 0.1) * CFrame.fromEulerAnglesXYZ(0, 0, 0))
			wait(0.05)
		end
		val = true
		drawer.ClickDetector.MaxActivationDistance = 5
	end
end

drawer.ClickDetector.MouseClick:connect(onClicked)
