Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Remote event reading Gui argument as 'nil'?

Asked by 6 years ago

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.

0
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) Vulkarin 581 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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.

0
Well you're right about the hidden part but I personally wouldn't use a bindableevent for this Vulkarin 581 — 6y
Ad

Answer this question