-- update bruv

wait(1)
RunService.RenderStepped:Connect(function()

	for i,v in pairs(workspace.Map:GetChildren()) do

		local CamPos = workspace.CurrentCamera.CFrame.Position
		local vPos = v:GetPivot().Position

		CamPos = Vector3.new(CamPos.X, 0, CamPos.Z)
		vPos = Vector3.new(vPos.X, 0, vPos.Z)
		local dist = (CamPos - vPos).Magnitude

		dist = dist - 3000
		if dist < 0 then
			dist = 0
		end
		dist = dist*dist/3000
		local currentPos = CFrame.new(v:GetAttribute("OriginalPosition") - Vector3.new(0, dist/50, 0)).Position
	--[[
	local refinedPosHeight
	if v:isA("BasePart") then
		refinedPosHeight = Vector3.new(0, currentPos.Y + v.Size.Y/2, 0)
	else
		local cframe, size = v:GetBoundingBox()
		refinedPosHeight = Vector3.new(0, currentPos.Y + size.Y/2, 0)
	end

	if refinedPosHeight.Y < CamPos.Y - 200 then
		dist = 1000000
	end
	]]
		if not isPositionOnScreen(v:GetAttribute("OriginalPosition") - Vector3.new(0, dist/50, 0)) then
			dist = 100000000

			v:PivotTo(CFrame.new(v:GetAttribute("OriginalPosition") - Vector3.new(0, dist/50, 0)) * v:GetPivot().Rotation)
		elseif isPositionOnScreen(v:GetAttribute("OriginalPosition") - Vector3.new(0, dist/50, 0)) then
			v:PivotTo(CFrame.new(v:GetAttribute("OriginalPosition") - Vector3.new(0, dist/50, 0)) * v:GetPivot().Rotation)
		end


	end
end)
