I need help with locating object

So i want to be able to find the closest object (to the player) with certain hash, and get the coords of that object.

local player = GetEntityCoords(PlayerPedId())
local door = GetClosestObjectOfType(player, 1.0, -973122415, false, false, false)
local coords = GetEntityCoords(door)

I have tried like this but as you can probably already tell it did not work. If you have a way i can make that work could you please help me out?

for use like a Debug tool?

Nope. I need it for a robbery script where it will open the closest door for you. And for that function i need the vector3 coords of the closest door.

if you know the model name of door you can do something like this :slight_smile:

while true do
if IsControlJustPressed(0,20) then
local x,y,z = table.unpack(GetEntityCoords(PlayerPedId(),true))

“v_ilev_ph_gendoor004" this is an example model name

you change this to the model you use

and then stand next to door press Z and it will print

did this work

Yes. But my one also worked. After research i found out that the error was not with my script but the map i was using. Sorry for wasting your time but yes yours did work and helped me to debug the script so thanks.

1 Like