Closest ped/hunting script help

So im trying to make a hunting script and i need some help with the last and hardest part of the script.
so now a short explenation of what i want/need():

Citizen.CreateThread(function()
    while true do

        Citizen.Wait(5)
		
		local playerCoords = GetEntityCoords(PlayerPedId())
		
        local ped = GetClosestPed(playerCoords)

		if ped = 'a_c_deer' then 	
		
			local pedhealth = getentityhealth(ped)
			
			if pedhealth <=0 then
			
				local AnimalBlip = AddBlipForEntity(ped)
				SetBlipSprite(AnimalBlip, 442)
				SetBlipColour(AnimalBlip, 3)
				SetBlipScale(AnimalBlip, 1.0)
				BeginTextCommandSetBlipName("STRING")
				AddTextComponentString('dead animal')
				EndTextCommandSetBlipName(AnimalBlip)
			end
		end
	end
end)	

thanks