Using SteamID() on a string

I have an argument that a player has to enter either a SteamID or a player’s nick but since this is considered a string I can’t run

Player:SteamID on it. Is there any way to make it so that I can run SteamID() on the argument?

If you mean you want to run SteamID on a player’s nickname, then you have to find the player with the nickname, which you do with a simple loop like this:



local function GetSteamIDFromNickname( namestring )
    for k,v in pairs( player.GetHumans() ) do -- loop through all players
        if v:Nick() == namestring then return v:SteamID() end -- if the name entered was the nickname of the player then return the ID
    end
    return false -- no player with the nickname provided was found on the server
end


Then again, it’s possible for people on the server to have the same nickname, so you might want to add it to a table and then return it instead