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)
print(coords)

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:

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlJustPressed(0,20) then
local x,y,z = table.unpack(GetEntityCoords(PlayerPedId(),true))
print(GetEntityCoords(GetClosestObjectOfType(x,y,z,2.0,“v_ilev_ph_gendoor004”,false,false,false),true))
end
end
end)

“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