[Help] Simple player blips script

I tried coding this blip script that shows player blips on the map but the player’s name is replaced with the license plate of the vehicle he’s driving. The script works, only thing is, I need to restart the resource every time I change vehicles so the plate number updates on the map. Also, my blip rotation doesnt seem to work, doesn’t match the heading the player is looking at. doesnt move at all. Anybody able to help? I’d appreciate it very much. code:

Citizen.CreateThread(function()
	local blips = {}
	local currentPlayer = PlayerId()
	Wait(1)
	
		for player = 0, 64 do
			if player ~= currentPlayer and NetworkIsPlayerActive(player) then

				local playerPed = GetPlayerPed(player)
				local playerName = GetPlayerName(player)
				local veh = GetVehiclePedIsIn(playerPed, false)
				local new_blip = AddBlipForEntity(playerPed)
				
				SetBlipSprite(new_blip, 423)
				SetBlipColour(new_blip, 0)
				
				local plate = GetVehicleNumberPlateText(veh)
				BeginTextCommandSetBlipName("string")
				AddTextComponentSubstringPlayerName(plate)
				EndTextCommandSetBlipName(new_blip)

				ShowHeadingIndicatorOnBlip(new_blip, true)
				SetBlipRotation(new_blip, math.ceil( GetEntityHeading(ped)))
				
				SetBlipScale(new_blip, 1.0)
				SetBlipDisplay(new_blip, 2)
				
				end
			end
end)

solved

Would be nice if you shared your solution to others also trying to achieve this :smiley:

Any chance you could release your working script?