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!