This post has been solved. Futher assistance is not required.
GetUserIdFromNameAsync
is a Player Service function that requires a user id parameter, it cannot be called on a player
To get the UserId you can just do
local UserId = game:GetService("Players"):GetUserIdFromNameAsync(plr)
Nope, there is a new error saying ‘Argument 1 is missing or nil’.
Is the plr variable being passed through? Is it a player’s name or the player themself?
Post has been deleted by the author.
This should fix it.
local UserId = game:GetService("Players"):GetUserIdFromNameAsync(plr.Name)
Explanation:
Basically in the documenation for GetUserIdFromNameAsync
it says that you need to use the Players as a whole not one singular player, and call the function with the player’s name, more on here.
Nope, there is a new error tho.
18:09:42.570 ServerScriptService.ModerationPlus:6: attempt to index nil with 'Name' - Server - ModerationPlus:6
I managed to fix it.
I needed to add plr.Name at
local plr = game:GetService(“Players”):FindFirstChild(plr)
Thanks for the help!
“plr” was nil because you hadn’t defined it, his/her script would’ve worked if you had defined a player object and assigned it to a variable named “plr”.
this got solved like 3 hours ago, for me it’s 12 pm so please don’t mention me
local players = game:GetService("Players")
local player = players.LocalPlayer
local playerId = player.UserId
local playerName = player.Name
local playerNameFromId = players:GetNameFromUserIdAsync(playerId)
local playerIdFromName = players:GetUserIdFromNameAsync(playerName)
local playerFromId = players:GetPlayerByUserId(playerId)
Here’s just a small example of how everything works, and how you can use it in the future.
this topic got solved if
-
the solution don’t work for you
-
you have details
then reply, if you dont meet these 2 things and u reply, im flagging u k thx