How do i make specific peds attack a specific player?

Hi I have just started developing with natives so I’m pretty new to it and I’ve ran into a problem. The thing i’m coding is a quest where you steal a car and drive it to a location. But I whant some peds to attack you when you try to steal it. So what i first did was to spawn in the peds then do so that when i am close enough they get guns and then i set the relationship between the peds and the player so that they attack me. But the only thing they do is aim at me and when i get closer to them they just punch me with their guns.

Here is the code:

Citizen.CreateThread(function()
                while true do
                    Citizen.Wait(0)
                    local coords = GetEntityCoords(PlayerPedId())

                    if GetDistanceBetweenCoords(coords.x, coords.y, coords.z, 270.86, -1928.47, 25.17, true) <= 10 then
                        GiveWeaponToPed(SpawnObject3, GetHashKey("WEAPON_COMBATPISTOL"), 50, false, true)
                        GiveWeaponToPed(SpawnObject4, GetHashKey("WEAPON_MICROSMG"), 50, false, true)
                        GiveWeaponToPed(SpawnObject5, GetHashKey("WEAPON_COMBATPISTOL"), 50, false, true)

                        local PlayerHash = GetHashKey(PlayerPedId())
                        local PedHash1 = 653210662
                        local PedHash2 = -1773333796
                        local PedHash3 = 653210662


                        SetRelationshipBetweenGroups(4, PlayerHash, PedHash1)
                        SetRelationshipBetweenGroups(4, PedHash1, PlayerHash)

                        SetRelationshipBetweenGroups(4, PlayerHash, PedHash2)
                        SetRelationshipBetweenGroups(4, PedHash2, PlayerHash)

                        SetRelationshipBetweenGroups(4, PlayerHash, PedHash3)
                        SetRelationshipBetweenGroups(4, PedHash3, PlayerHash)
                    end
                end
            end)

But that didn´t work so Instead of using the SetRelationshipBetweenGroups i tried this:

Citizen.CreateThread(function()
                while true do
                    Citizen.Wait(0)
                    local coords = GetEntityCoords(PlayerPedId())

                    if GetDistanceBetweenCoords(coords.x, coords.y, coords.z, 270.86, -1928.47, 25.17, true) <= 10 then
                        GiveWeaponToPed(SpawnObject3, GetHashKey("WEAPON_COMBATPISTOL"), 50, false, true)
                        GiveWeaponToPed(SpawnObject4, GetHashKey("WEAPON_MICROSMG"), 50, false, true)
                        GiveWeaponToPed(SpawnObject5, GetHashKey("WEAPON_COMBATPISTOL"), 50, false, true)

                        local SpawnObject3 = CreatePed(9, PedHash1, 268.99, -1926.82, 24.21, -130.00, true)
                        local SpawnObject4 = CreatePed(9, PedHash2, 270.04, -1929.59, 24.13, 140.00, true)
                        local SpawnObject5 = CreatePed(9, PedHash3, 267.16, -1930.21, 24.12, 5.00, true)


                        TaskCombatPed(SpawnObject3, GetPlayerPed(-1), 0, 16)
                        TaskCombatPed(SpawnObject4, GetPlayerPed(-1), 0, 16)
                        TaskCombatPed(SpawnObject5, GetPlayerPed(-1), 0, 16)
                        
                    end
                end
            end)

But that didn´t work ethear?

If you know whats wrong pleas help me.