local function click(player)
player.PlayerGui.Shop.Frame.Visible = true
end
script.Parent.ClickDetector.MouseClick:connect(click)
PlayerGui is not a Valid member of Player?
2 answers
You don't use a click detector like that lol. Put this code in a LocalScript, in a ScreenGui in StarterGui, but not inside the Frame. Remember to put the LocalScript inside of a TextButton.
script.Parent.MouseButton1Click:Connect(function() -- TextButton's have their own mouse click event.
script.Parent.Parent.Frame.Visible = not script.Parent.Parent.Frame.Visible
end)
Review: In line 1, we set up the event. Line 2, we change the Visible state of the frame to its opposite, "not true" is false and vice versa. Follow the first steps. Where to put it.
2 comments
It's not a text button it's click detector on a npc
Why on earth do you have a ClickDetector on an NPC? NPC's shouldn't have ClickDetectors!
If you're using FE, this won't work because scripts can't run or change the player's playergui, only localscripts can. Even if FE is off, this is very bad practice because you only need a LocalScript, since the PlayerGui is on the client, not for all the clients. In a nutshell, only use localscripts if you want to make changes on client only, and scripts to do things that show up on all clients. But if you wanted to change it for all clients, well, you would need a remoteevent since as I said earlier, scripts can't access playergui with FE on.
2 comments
And, MouseClick won't work in a LocalScript, just in case you're using one.
Basically, to get this working, add a remote event in replicatedstorage, make the script fire it, then the localscript handles the event and turns the gui on.
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Print the player: print(player) and see if it is a actual player or not.
Yea it's working
Oh wait now the error changed to Shop is not a valid member of PlayerGui...
You will probably have to use RemoteEvents for this as ClickDetectors work by server only and not client.