I am trying to fire an event when pressing a TextButton to open a Gui panel, but upon supplying a variable pointing to one of the buttons ancestors, it creates and error saying: "Workspace.HandlePlayers:86: attempt to index local 'GUI' (a nil value)" Here is my LocalScript inside my TextButton:
GUI = script.Parent.Parent.Parent script.Parent.MouseButton1Click:Connect(function() game.ReplicatedStorage.Events.NewGame:FireServer(GUI) print("OpenNewGameGui") end)
And here is a part of my server script:
events.NewGame.OnServerEvent:Connect(function(plr,GUI) local main = GUI.Main main.NewGameSlots.Visible = true main.LoadGameSlots.Visible = false main.ShopFrame.Visible = false main.CreditsFrame.Visible = false end)
"events" is a variable leading to where I have placed all of my remote events.
I've double checked my parents of my Button several times, and have had no clue what to do to fix this. I tried plugging in a int variable as another argument and the remote event received it fine. Thanks in advance for the help.
All player gui's are hidden from the server. Only the clients can interact with them. Try using a "BindableEvent" to communicate with the gui instead.