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

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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.

Ad
Log in to vote
0
Answered by
2eggnog 981 Moderation Voter
5 years ago
Edited 5 years ago

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.

Answer this question