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?
game.Players(b)
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.