So I tried doing this, but I still couldn’t get it to work.
I brainstormed for a bit, and came to the conclusion that I could get the entity individually, on every client, thanks to the coordinates of the player opening the barrier:
TriggerServerEvent('esx_kriza_bridge_toll:opengate', position, true)
--Event gets sent to server, and then back to every client
RegisterNetEvent('esx_kriza_bridge_toll:open')
AddEventHandler('esx_kriza_bridge_toll:open', function (pos, open)
local gate = GetClosestObjectOfType(pos.x, pos.y, pos.z, 750.0, GetHashKey('kriza_barrier_props'), 0, 0, 0)
if open then
for i=-180, -90, 1 do
Citizen.Wait(Config.Speed)
local rotation = int2float(i)
SetEntityRotation(gate, 0.0, rotation, GetEntityRotation(gate, 2).z, 2, true)
end
else
for i=-90, -180, -1 do
Citizen.Wait(Config.Speed)
local rotation = int2float(i)
SetEntityRotation(gate, 0.0, rotation, GetEntityRotation(gate, 2).z, 2, true)
end
end
end)
Hope this will help anyone who has the same issue as me 