SCRIPT ERROR: Execution of native 000000002f7a49e6 in script host failed: Argument at index 1 was null. Please help me!

Hey! I am trying to do a script that when you go to a specific npc he gives you a mission, and you can only do the mission one time per day. Everything works until I try to do this function I get this error and I cant figure out why. It would help me alot if you helped me with this problem!

Screenshots:

Screenshot 2021-05-28 212453

try saving source in a variable and then forward that to the event, for example add this above your local xPlayer = ESX.GetPlayerFromId(source)

local source = source