Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Acratixx is not a valid member of Players error Help me?

wait()

script.Parent.Touched:connect(function(Hit)

local a = Hit.Parent:FindFirstChild("Humanoid")

local b = a.Parent.Name

local c = game.Players(b)

b.PlayerGui.Shop.Frame.Visible = true

end)

I'm trying to make it so that when you touch a part, it makes the frame of a ScreenGui Visible, which does not work because it says that there is an error in line 5 where Acratixx is not a valid member of Players, when i am clearly in the game. Any Ideas on how to fix this?

2 answers

✓ Accepted answer

###Since you did not paste your code in code blocks, I cannot tell which line it is on. But it is this line:

game.Players(b)

###You are treating Players as a function. You index objects with square brackets ([]), not brackets.

game.Players[b]

Also, you should not handle GUI on the server, use a RemoteEvent to access PlayerGui from the client.

To obtain a player by name, you should do:

game.Players:FindFirstChild(b)

Alternatively, you can do:

game.Players[b]

... but this isn't recommended because throws an error instead of returning nil when the player doesn't exist.

This discussion is preserved as it was. New answers, comments, and votes are closed.