[HELP] Command Help

I tried to make a command to store data on the player. My code below

local user = {}

RegisterCommand('setdata', function(source, ya)
    TriggerClientEvent('chat:addMessage', source, {
        args = { 'Variable set to '..ya[1] }
    })
	TriggerEvent("setElementData", source, source, "test", ya[1])
end, false)

AddEventHandler("setElementData", function(player, var, val)

	user.player[var] = val -- Line 12
	
end)

and i got error

@commands/server.lua:12: attempt to index a nil value (field 'player')