Source from 'playerSpawned'

hi there im calling a server event when a player spawns however i just cant pass the source from client side to server side here is the client side

local firstspawn = 0
AddEventHandler(‘playerSpawned’, function(spawn)
if firstspawn == 0 then
TriggerServerEvent(‘InitPlayer’,source)
firstspawn = 1
end
end)

and server side

RegisterServerEvent(‘InitPlayer’)
AddEventHandler(‘InitPlayer’, function(source)
local player = GetPlayerIdentifiers(source)[1]
local source = source
TriggerEvent(‘CoaRP:getPlayer’, source, function(user)
local playerName = user.getName()
MySQL.Sync.execute(“UPDATE user_appartement SET isOnline = 1 WHERE identifier = @identifier”, {[’@identifier’] = player})
MySQL.Sync.execute(“UPDATE user_appartement SET serverid = @serverid WHERE identifier = @identifier”, {[’@identifier’] = player, [’@serverid’] = source})
MySQL.Sync.execute(“UPDATE user_appartement SET username = @username WHERE identifier = @identifier”, {[’@username’] = playerName, [’@identifier’] = player})
end)
end)

the source is nill for some reason

You dont neet to put source after that (It should get it itself if it is triggering fron client side?). Try without it like:
TriggerServerEvent(‘InitPlayer’)

1 Like

yeah it was without it but for some reason it doesnt pass the source . i just used this instead

local playerName = GetPlayerName(source)

this will get the steam username . i really need to understand more what type of source gets passed to the server side i think in this case its different from the source where for exemple a player presses a button and then calls a server event .

Have you tried to remove (source) from both AddEventHandler? (client and server side) I had similar problem and solved it like that.

1 Like

yeah i tried it but no luck XD i gave up on it . thanks for your help i ll delete this thread