Help with passing a function to the server side

Well, I am trying to pass the hasKeys(plate) function to the server-side so when players disconnect don’t have to hotwire their own vehicles - but I faced some problems trying to make it work
I’m not even sure if that’s the right way to do it or do I need to create a variable for it

here’s my code so far:

TriggerServerEvent('pb-hotwire:server:givePlayerKeys', plate)

I used this to call a server event instead of using the giveplayerkeys directly

This is the server event:

RegisterServerEvent('pb-hotwire:server:givePlayerKeys')
AddEventHandler('pb-hotwire:server:givePlayerKeys', function(plate)
	TriggerClientEvent('pb-hotwire:client:givePlayerKeys', source, plate)
end)

and this is what I added on my client.lua

RegisterNetEvent('pb-hotwire:client:givePlayerKeys')
AddEventHandler('pb-hotwire:client:givePlayerKeys', function(plate)
  givePlayerKeys(plate)
end)

givePlayerKeys() function

function givePlayerKeys(plate)
    local vehPlate = plate
    table.insert(vehicles, vehPlate)
end

My second though was to use a second variable but I really do not know the right way to do this
I tried several stuff and looked over different scripts but I couldn’t succeed in the end
I hope someone will help

From what I can see, you’re trying to save what cars the player should have access to. That depends on what the table ‘vehicles’ does and how you use it, everything so far seems fine. You trigger a server event to trigger a client event which saves the vehicles number plate in the ‘vehicles’ table. So now you just have to check that ‘vehicles’ table when they try to open a car.