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.
Hey, try adding :Clone()
to Line 1. As it is right now, it is just relocating the GUI, not creating a separate one then moving it. This might be your issue. Also, make sure capitalization is the same on the script as it is in the Explorer.
local gui = game.ServerStorage.notes:Clone() script.Parent.MouseButton1Click:Connect(function(plr) print("click") gui.Parent = plr.PlayerGui end)