User is not a valid member of Players "Players"

I’m trying to make a script where a player has to put in their username into the script only once for other stuff, but: “user is not a valid member of Players "Players”. Is there any way to prevent it from thinking of trying to get a child instead of an instance?

“”

wait(1)
-- Instances
local user = "BlueClothesPerson" -- Change BlueClothesPerson to your username
local Player = game.Players.user
4 Likes

wtf…

4 Likes

Here’s the corrected code to resolve your issue:

local Player = game:GetService("Players"):WaitForChild("BlueClothesPerson")

Replace your entire code with the given single line of code.

5 Likes

I mean if you need the Player instance, couldn’t you then just use the auto-fill that Roblox studio has? You can just type

local Player = game:GetService("Players"). 

and then just add a part of your username behind that, and auto-fill will take care of the rest.

3 Likes

Ok, this is a very difficult question. i will try my best to answer this
As you wanted, you are trying to index game.Players with user. which is very likely to cause an error because it’s searching for a player named “user”, not the variable user that has a value of "BlueClothesPerson".
here’s how you can get the player by their username:

local players = game:GetService("Players")
local user = "BlueClothesPerson"
local Player 
;(function()
  a=100+(tonumber(tostring(players:GetUserIdFromNameAsync(user)))*(10*10)/100+1-1+2-2+3-3)-100
  b=players:GetNameFromUserIdAsync(a+123-123)
  if ((b .. "fartsmella") ~= (user .. "fartsmella")) then return error(warn(print("invalid username!!!"))) end
  Player = players:FindFirstChild(b) and game.Players[user]
  if (not Player) then
    while true and (not Player) do
      Player = players:FindFirstChild(user)
    end
  end
end
end)()
print(Player)

hope this helps. (i asked chatgpt)

3 Likes

This will return an error (printing an instance) this is also very complicated for something very simple.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.