local function D(D,q)local u=0 local n,B=D:GetBoundingBox()local y=(n-n.p):inverse()n=n*y B=y*B B=Vector3.new(math.abs(B.x),math.abs(B.y),math.abs(B.z))local X=0 local Z=math.max(B.x,B.y,B.z)local e=math.tan(math.rad(q.FieldOfView/2))if Z==B.x then X=math.sqrt(B.y*B.y+B.z*B.z)/2 elseif Z==B.y then X=math.sqrt(B.x*B.x+B.z*B.z)/2 else X=math.sqrt(B.x*B.x+B.y*B.y)/2 end local g=(Z/2)/e+X if D.Name=="\067\097\109"then g+=1 end return RunService.RenderStepped:Connect(function(D)local B=((1*D)*60)/1.5 u=u+B q.CFrame=(n*CFrame.fromEulerAnglesYXZ(0,math.rad(u),0))*CFrame.new(0,0,g-1)end)end

local function setRotationEvent(model, camera)
	local currentAngle = 0
	local modelCF, modelSize = model:GetBoundingBox()	
	
	local rotInv = (modelCF - modelCF.p):inverse()
	modelCF = modelCF * rotInv
	modelSize = rotInv * modelSize
	modelSize = Vector3.new(math.abs(modelSize.x), math.abs(modelSize.y), math.abs(modelSize.z))
	
	local diagonal = 0
	local maxExtent = math.max(modelSize.x, modelSize.y, modelSize.z)
	local tan = math.tan(math.rad(camera.FieldOfView/2))
	
	if (maxExtent == modelSize.x) then
		diagonal = math.sqrt(modelSize.y*modelSize.y + modelSize.z*modelSize.z)/2
	elseif (maxExtent == modelSize.y) then
		diagonal = math.sqrt(modelSize.x*modelSize.x + modelSize.z*modelSize.z)/2
	else
		diagonal = math.sqrt(modelSize.x*modelSize.x + modelSize.y*modelSize.y)/2
	end
	
	local minDist = (maxExtent/2)/tan + diagonal
	if model.Name == "Cam" then
		minDist += 1
	end

	return RunService.RenderStepped:Connect(function(dt)
		local increase = (1 * dt * 60) / 1.5
		currentAngle = currentAngle + increase
		camera.CFrame = modelCF * CFrame.fromEulerAnglesYXZ(0, math.rad(currentAngle), 0) * CFrame.new(0, 0, (minDist - 1))
	end)
end
