Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GetUserIdFromNameAsync keeps returning an error saying no user exists?

Asked by 4 years ago

I'm making an admin script, and using noblox-js to rank players from a chat command.

I am getting the error: Players:GetUserIdFromName() failed because the user does not exist

I'm taking the second argument for the players name, which I then fire to the client, which then fires back to the server to rank the player. Everything is working, and the name prints in the final destination script, which is the the Server Script that ranks the player. Not sure why it wouldn't be working. The player name is correct, and plrToRank has the correct name value, but it says that the user does not exist.

CommandHandler(Specified to ranking command.)

commands.jrb = function(sender, arguments)

    if getadmins(sender) then
        for i,playerName in pairs(arguments) do
            print(playerName)
        end

        local playerToRankName = arguments[1]

        if playerToRankName then
            game.ReplicatedStorage.JRB:FireAllClients(playerToRankName)
        end
    end
end

Local Script(Which then fires server.)

local rep = game:GetService("ReplicatedStorage")
local jrb = rep:WaitForChild("JRB")
local bar = rep:WaitForChild("Barista")
local srb = rep:WaitForChild("SRB")

jrb.OnClientEvent:connect(function(plrToRank)
    print("Ranking "..plrToRank)
    jrb:FireServer(plrToRank)
end)

Ranking Server Script

local GroupId = 6151289
    local HttpService = game:GetService("HttpService")
    local Server = require(script.Server)
    local domain = "removed for privacy reasons."
    local key = "removed for privacy reasons."
    local Players = game:GetService("Players")

local JRB = game.ReplicatedStorage.JRB
local Barista = game.ReplicatedStorage.Barista
local SRB = game.ReplicatedStorage.SRB

JRB.OnServerEvent:Connect(function(Player, plrToRank)
    local userId = Players:GetUserIdFromNameAsync(plrToRank)
    Server.SetRank(GroupId, userId, 240)
    print(plrToRank.." has been ranked Junior Barista")
end)

Barista.OnServerEvent:Connect(function(Player, plrToRank)
    local userId = Players:GetUserIdFromNameAsync(plrToRank)
    Server.SetRank(GroupId, userId, 241)
    print(plrToRank.." has been ranked Barista")
end)

SRB.OnServerEvent:Connect(function(Player, plrToRank)
    local userId = Players:GetUserIdFromNameAsync(plrToRank)
    Server.SetRank(GroupId, userId, 242)
    print(plrToRank.." has been ranked Senior Barista")
end)

Answer this question