Why does my game break when i do this

my game working - YouTube before i changed it
my game breaks - YouTube after i changed it

I didnt know what to search on devforum to fix this so i just made a new post

the problem is that the game works completely fine when the camera only goes left and right. but it annoyed me that when my character was out of frame i couldnt see it, so i made the camera go up and down too, but for some reason that caused the blocks to noclip and stick onto each other

heres some of the code from my script

for _,obj:GuiObject in pairs(getObjects()) do
		if obj:GetAttribute("Anchored") == false then
			local velocityX = obj:GetAttribute("VelocityX")
			local velocityY = obj:GetAttribute("VelocityY")
			local newpos
			local touchedObj = touching(obj)
			if touchedObj then
				local bounce = true
				velocityY = -(velocityY / 2)
				if bounce and velocityY <= 0 then
					obj:SetAttribute("VelocityY", math.round(velocityY))
				else
					velocityY = 0
				end
				newpos = obj.Position + UDim2.fromOffset(0, velocityY)
			else
				velocityY = velocityY + (script:GetAttribute("Gravity")/100)
				obj:SetAttribute("VelocityY", velocityY)
				newpos = obj.Position + UDim2.fromOffset(0, velocityY)
			end
			local posTouchedobj = touchingPos(newpos, obj)
			if touchedObj then
				if newpos.Y.Offset >= (touchedObj.AbsolutePosition.Y - obj.AbsoluteSize.Y) and newpos.Y.Offset <= (touchedObj.AbsolutePosition.Y) then
					obj.Position = UDim2.fromOffset(obj.Position.X.Offset, (touchedObj.AbsolutePosition.Y - obj.AbsoluteSize.Y))
				end
			else
				obj.Position = newpos
			end
			if velocityX < 0 then
				velocityX = velocityX + (script:GetAttribute("Gravity")/200)
			elseif velocityX > 0 then
				velocityX = velocityX - (script:GetAttribute("Gravity")/200)
			end
			obj:SetAttribute("VelocityX", velocityX)
			obj.Position = obj.Position + UDim2.fromOffset(velocityX, 0)
		elseif obj:GetAttribute("Type") == "Player" and obj ~= Player then
			-- Nothing
		end
	end

Can I see the both versions of the code please, so I can compare them both. Thanks. There is no camera code in this bit you have pasted so it’s difficult to see any changes to the camera, or indeed what those changes were, i.e. before up-down movement, and after up-down movement. If you are simulating a camera offset there is no main GUI here that you are repositioning over to simulate a camera moving so without that it is hard to see anything that is wrong in your snapshot of code.

you used: for _,obj:GuiObject in pairs(getObjects()) do so how many instances does “obj:GuiObject” have?

i advice to add a Wait() a the end of the code to prevent lag

here is camera script:
before:

function camFollow(obj)
	local camSpeedX = obj:GetAttribute("VelocityX")
	if camSpeedX < 0 then
		camSpeedX = 0 - camSpeedX
	end
	local x = -(obj.Position.X.Offset - (workspaceFrame.AbsoluteSize.X/2) + (obj.Size.X.Offset/2))
	local Pos = UDim2.fromOffset(x, 0)
	workspaceFrame.Position = Pos
end

after:

function camFollow(obj)
	local camSpeedX = obj:GetAttribute("VelocityX")
	local camSpeedY = obj:GetAttribute("VelocityY")
	if camSpeedX < 0 then
		camSpeedX = 0 - camSpeedX
	end
	local x = -(obj.Position.X.Offset - (workspaceFrame.AbsoluteSize.X/2) + (obj.Size.X.Offset/2))
	local y = -(obj.Position.Y.Offset - (workspaceFrame.AbsoluteSize.Y/2) + (obj.Size.Y.Offset/2))
	local Pos = UDim2.fromOffset(x, y)
	workspaceFrame.Position = Pos
end