Player Leaving Before Saving User ID

Hey Guys! I am developing a leave/join Discord Webhook module, but whenever I try to run the leave notifier function, it will say an error like Attempt to index nil with 'Name' when I am trying to refer to player.Name. Here is the base script that sends the User ID to the module:

game.Players.PlayerRemoving:Connect(function(plr)
	local userId = plr.UserId
	module.sendLeaveMsg(webhook, userId)
end)

I’m just confused because I’m already saving the userId. Here is where I call it:

function module.sendLeaveMsg(webhook, userId)
        local plr = players:GetPlayerByUserId(userId)
        ... -- plr.Name is being called later in the script
end)

The ... just resembles the rest of the script that should work.
If you can help me, please do! Thanks!

1 Like

This no longer works in Roblox Studio. Try in the actual game?

What do you mean by that?

aaaaaa

hit the play button on the website and not playtest button in studio
also, discord doesn’t like it when you spam webhooks so just keep that in mind

If you have 2-10k players, this will get your webhook banned. You can’t have over 10k requests per 10 minutes. Why do you need this?

I don’t really care if my webhook gets banned. I’ll just make another one. And I don’t make games; I sell this stuff

Having your webhook get banned can have a chance at banning your own discord account. You care about that, don’t you?