Position tracking system not working correctly

local function TrackingSystem()

	wait(1)
		-- playernumber2 = touchedcheckpointsnumber
		-- player.PlayerGui:FindFirstChild("TrackGUI").TextLabel.Text = playernumber2.." / "..carsnumber
		-- player.PlayerGui:FindFirstChild("TrackGUI").LapsLabel.Text = "Laps: "..lapsnumber.." / "..totallaps
		
		while wait(1) do
		if game.Players.LocalPlayer.Character.Humanoid.Seated then
			local localcar = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").SeatPart.Parent
		for i,v in pairs(values:GetChildren()) do

			for i,v in pairs(cars:GetChildren()) do
				local car1 = v
				for i,v2 in pairs(cars:GetChildren()) do
						local car2 = v2
						if car1 ~= localcar then
							local distance = math.abs((car1.Root.Position - localcar.Root.Position).magnitude)
							
					-- if car1.VehicleSeat.Occupant == game.Players.LocalPlayer then
					if distance == 0 then
						local currentcar = car1
							end
							
							if distance >= 15 then
								number = number + 1
								player.PlayerGui:FindFirstChild("TrackGUI").TextLabel.Text = number.." / "..carsnumber
							else
								local number = carsnumber
								number = number - 1
								player.PlayerGui:FindFirstChild("TrackGUI").TextLabel.Text = number.." / "..carsnumber
							end
							
						print("local players distance to "..car1.Name.." = "..distance) -- testing purposes :/
						-- end
						
				
					if distance > 0 and correct == false then
					elseif correct == false then
					end
				end
	
			-- if type(playernumber2) == "number" then
			-- if 	playernumber2 % 1 == 0 then
				

			--  end
			end
			end
				
			end
			end
			-- end

title explains it all, this code is supposed to rank players from 1 to total of cars but it doesn’t and I don’t know why. any help will be appriciated

1 Like