Hello, I’m fairly new to fiveM scripting and am working on one of my first scripts so spare me if I make some mistakes.
What I want to do with the first part of this script is get the hash of the vehicle a player is shooting at.
Code I have
Citizen.CreateThread(function()
local player = PlayerId()
local ped = GetPlayerPed(-1)
while ESX == nil do
Citizen.Wait(0)
if IsPlayerFreeAiming(player) then
if IsPedShooting(ped) then
local aiming, entity = GetEntityPlayerIsFreeAimingAt(player, Citizen.ReturnResultAnyway())
if IsEntityAVehicle(entity) then
print('Shooting at car')
else
print('Not shooting at car')
end
end
end
end
end)
Problem: When there isn’t a player in the vehicle it works fine but when there is it prints “Not shooting at car” to the console
Expected Result: I want the program to acknowledge that I am shooting at a car even if there is a player in it.