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.

1 comment
If you're doing GUI manipulation then forget the entire server script, the client is the only one capable of manipulating their GUIs (have the local script change the properties by itself)