Need help with join message

I’m trying to make a global message that is supposed to tell everyone that someone is joining however the script causes the server to be unaccessable and just gets me stuck on ‘Obtaining Steam Key’ or something along those lines

This is the code

AddEventHandler('playerConnecting', function(playerName)
	TriggerEvent('chatMessage', playerName, {255, 255, 255}, "is joining!")
end)

Try this

TriggerClientEvent(‘chatMessage’, source, playerName, {255, 255, 255}, “is joining!”)

Hi,
probably related: HANG/or interrupt on playerConnecting event
Try to add the trigger in a SetTimeout callback.

should I also add in the source like this?

AddEventHandler('playerConnecting', function(source, playerName)

or leave it as

AddEventHandler('playerConnecting', function(playerName)

in server.lua

AddEventHandler('playerConnecting', function(playerName, setKickReason)
	TriggerClientEvent('chatMessage', -1, {255, 255, 255}, playerName .. " is joining!")
end)

Edit by Havoc: Made the function follow the syntax from the wiki

1 Like

doesn’t work, no chat message and no console errors :frowning:

You can’t see your own joining message

I got my friend to join while I was in the server and nothing popped up

Then something is wrong somewhere else, this can only work

What about this one?

AddEventHandler('playerConnecting', function(playerName, setKickReason)
	TriggerClientEvent('chatMessage', -1, "", {255, 255, 255}, playerName .. " is joining!")
end)

Thanks, that works perfectly! <3

Hey, is there a way to get the player’s network id from this event? Or maybe another event that fires when the player is completely connected? Because I see the “player has joined!,” so it must be an event that fires when the player has established a connection.