Issue with IsAceAllowed

Im trying to make a discord donator car menu, using ace perms to spawn cars.

Code:

local SAHPVehicles = _MenuPool:AddSubMenu(MainMenu, Config.SAHPName, "Choose a pack!", true)
        SAHPVehicles:SetMenuWidthOffset(Config.MenuWidth)
            if SAHPVehicle1() then
                local SAHP1 = NativeUI.CreateItem(Config.SAHPVehicleName1, "")
                SAHPVehicles:AddItem(SAHP1)
		if IsAceAllowed(source, "donatorone") then
                    SAHP1.Activated = function(ParentMenu, SelectedItem)
                        spawnCar(Config.SAHPSpawnCode1)
                        notify(Config.SAHPVehicleNotifcatoin1)
                    end
        	else
		    notify("~y~Error: ~w~You don't have the required permission to spawn this vehicle.")
		end
 end

I get the error:

SCRIPT ERROR: Execution of native 000000007ebb9929 in script host failed: Argument at index 0 was null.

Can anyone help me solve this issue?

I could only find a few resources regarding this:
https://githubmemory.com/repo/citizenfx/natives/issues/377

there is also this, which is more likely:

I think the reason your code is throwing that error is because “source” isn’t defined. So in the last forum post I linked this comment:

“You’d have to query all users from the db who has the job ems and cop and then check when executing the commands if the user is actually in there, if he is execute, if not then ignore.”

you would have to replace what they’re talking about with the “job ems and cop” with your donator.

IsPlayerAceAllowed is a server side native and you’re attempting to call it from the client, you can use IsAceAllowed instead. Alternatively (assuming you’re using OneSync) create an event and have the server spawn the vehicle for the player if they pass your check, having the server spawn entities instead of the client is considered a better practice anyway.

Now I am getting this error:

SCRIPT ERROR: Execution of native 000000007ebb9929 in script host failed: Argument at index 0 was null.

Since you are doing this client sided, source will be null, since no-one called that method.

Source is only allowed to be used server sided.

IsAceAllowed()

only takes one argument.

See fivem docs:
image

In short:
Change

if IsAceAllowed(source, "donatorone") then

To

if IsAceAllowed("donatorone") then