Hello, I am trying to make a Screen GUI pop up when a player clicks a button in a Surface GUI however when testing the script out it does not pop up and returns an error that 'plr' is a nill value.
This is my code...
local gui = game.ServerStorage.notes
script.Parent.MouseButton1Click:Connect(function (plr)
print("click")
gui.Parent = plr.PlayerGui
end)
And it outputs this when I click on the button.
17:30:53.589 -Workspace.Pure.dispatcher.desk.monitor.screen.SurfaceGui.welcome.notes.Script:5: attempt to index local 'plr' (a nil value)
17:30:53.590 - Stack Begin
17:30:53.590 - Script
'Workspace.Pure.dispatcher.desk.monitor.screen.SurfaceGui.welcome.notes.Script', Line 5
17:30:53.591 - Stack End
Thanks for any help.

4 comments
gui.Parent of game.ServerStorage.notes is just returning ServerStorage I think. You can't get player from ServerStorage, as it's server sided. If you need played, you'll need either a LocalScript or any event that has player, e.g. PlayerAdded (plr) or Touched (hit.Parent). To make this script work as it is, you should be looping through players and getting the right one, but I don't know how...
(gui.Parent = ServerStorage, can't get player)
Hierarchically is this script somewhere inside of the client's UI? Additionally, MouseButton1Click does not automatically pass a player argument as you seem to think it does (which is why your error occurs), if this is a LocalScript (and it should be) - set the parent to LocalPlayer's PlayerGui.
Oh, and as capinbuilda mentioned - it makes a lot more sense to clone the GuiObject rather than just move it.