Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Remote event reading Gui argument as 'nil'?

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

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)

1 answer

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.

1 comment

0

Well you're right about the hidden part but I personally wouldn't use a bindableevent for this

This discussion is preserved as it was. New answers, comments, and votes are closed.