When i test it in edit (play solo) it works fine but when i publish it and go in a online server, i get this error in the server output : Workspace.Merchant.Shop.ClickDetector.Shop:3 attempt to index local 'player' (a nil value)
this is the script (not a local script)
function onTouched() local player = game.Players.LocalPlayer player.PlayerGui.Shop.Shop.Visible = true end script.Parent.MouseClick:connect(onTouched)
Like zach785 stated, LocalPlayer is only accessible in Play Solo or Local Scripts. However, to rectify the issue, all you need to do is get a return from your function to see who clicked it.
function onTouched(hit) -- "hit" will return game.Players."PlayerWhoClicked" hit.PlayerGui.Shop.Shop.Visible = true end script.Parent.MouseClick:connect(onTouched)