Hey, nice to see youre updating that script but here are some recommendations since youve asked for feedback:
dont use GetPlayerPed(-1) just Cache the player’s ped once instead of calling GetPlayerPed(-1) multiple times. in Gta5 there’s PlayerPedId() which should be used and is also much faster.
( To be fair, I have that old habit too of doing it the old gta4 way lol )
local playerPed = PlayerPedId() – if youre wondering what I mean.
you can improve the iteration by using for i = 1, #players do instead of for _, player in ipairs(players) do. The ipairs loop incurs a slight performance overhead compared to direct indexing.
also Use vector operations for distance calculations instead of native functions like Vdist
Hey Thanks for letting me know didn’t realize there was more overhead with for _, player in ipairs(players) do also ill be looking into vector operations instead thanks for the insight , also i will move GetPlayerPed(-1) over to PlayerPedId()