Why does this print only occur when my player changes height

My script doesn’t seem to print this line every Heartbeat

print(player, Distance)

It prints all the other prints rapidly, but not the above print. The only way I can get it to print is if the local player moves.

-- Update the PlayerLabel positions
local function Update()
	if TotalSize <= 0 then return end
	print(TotalSize) -- Keeps printing
	for _, player in pairs(Players:GetPlayers()) do
		print(1) -- Keeps printing
		if player.Character and player.Character:FindFirstChild('HumanoidRootPart') then
			print(2) -- Keeps printing
			local PlayerLabel = PlayerList:FindFirstChild(player.Name)
			if not PlayerLabel then
				-- Create label
				PlayerLabel = CreateLabel(player)
			end
			
			-- Calculate players distance
			local Distance = player.Character.HumanoidRootPart.Position.Y - Start.Floor.Position.Y - 2
			if player ~= Player then
				print(player, Distance) -- ONLY prints when MY player moves
			end
			-- Set position
			PlayerLabel.Position = UDim2.new(0, 0, 1 - (Distance / TotalSize), 0)
			
			if Highest > Distance then return end
			
			Highest = Distance
			
			-- Set player's highest progress
			local ProgressLine = Frame:FindFirstChild('Progress')
			if not ProgressLine then return end
			
			ProgressLine.Visible = true
			
			-- Set progress line position
			ProgressLine.Position = UDim2.new(0, 0, 1 - (Highest / TotalSize), 0)
		end
	end
end

-- Update
RunService.Heartbeat:Connect(Update)

I’m assuming Player is your LocalPlayer? It looks to me that print(player, Distance) should print whenever your loop finds a player that isn’t LocalPlayer. You’re certain that’s not the case? It should have nothing to do with whether your player is moving. The only reason it shouldn’t print every heartbeat is if you are the only player in the game or if there is more to the script that you’re not showing.

Video displaying it in action.

print("Distance")
if player ~= Player then
	print(player, Distance)
end


In the video, I am player 2, so it printing Player1 is correct, but ye, only prints when I jump. To me, it should be spamming the ‘Player1 distance’ print just as much as it is spamming the ‘Distance’ print

Oh it’s probably the if Highest > Distance then return end that’s prematurely ending the function. Idk what Highest is but you probably wanna be using continue there.

Shouldn’t the script be running top to bottom tho? So it shouldn’t return until so

You’re correct. What I think is happening is that on the first iteration of the for loop, player is Player, so nothing prints (as intended). Then, it evaluates Highest > Distance, which returns the function. Consequently, the loop never makes it to the second player. However, when you jump, Highest <= Distance, so the function doesn’t return.

EDIT: BTW, to catch errors like this quicker in the future, use a breakpoint.