Hello! I’m creating an bank robbery script and i need help closing a door on player load.
Currently i tried to use normal stuff and it didn’t work i had to use while true do to fix it but thats not really an fix.
I think i know what the issue is, it’s the ESX.Game.GetClosestObject(nil, vector3(x,y,z))
I shouldn’t use nil but thats the only thing that works, i didn’t understand via looking at other peoples code.
My code :
function lockdoor(lock, x, y, z)
Citizen.Wait(1)
local coords = vector3(x,y,z)
local obs, distance = ESX.Game.GetClosestObject(nil, vector3(x,y,z))
FreezeEntityPosition(obs, lock)
end
Citizen.CreateThread(function()
lockdoor(true, 262.11251831055,221.86441040039,106.28517150879)
lockdoor(true, 252.42054748535,220.74656677246,101.68347930908)
lockdoor(true, 261.64138793945,215.13702392578,101.68347930908)
end)