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

Why is my gui frame having a nil error when i try to make the gui visible?

I'm making a gui in a way like lumber tycoon 2, you click menu and more options come up. Anyways i'm working on the first tab out of 5 and when i run the script everything works fine, i click U (to pop up the frame that is holding all the text buttons which are like 'Controls', 'Inventory' ect. And then when i click on the "Controls" text button which is supposed to make the Controls frame visible but then i come up with an error. I'll post the script and error.

local Button = script.Parent.Parent.Controls
local Frame = script.Parent.Parent.ControlsFrame

Button.MouseButton1Click:connect(function()
	ControlsFrame.Visible = true
end)

And here's the error.

06:18:24.858 - Players.Player1.PlayerGui.MenuGui.MenuFrame.Controls.LocalScript:5: attempt to index global 'ControlsFrame' (a nil value)

1 comment

0

Try to use WaitForChild.

1 answer

✓ Accepted answer

You set it to Frame, not ControllsFrame.

local Button = script.Parent.Parent.Controls
local Frame = script.Parent.Parent.ControlsFrame

Button.MouseButton1Click:connect(function()
Frame.Visible = true -- here
end)

2 comments

0

My bad, it was super early when i made this xD. But it still doesn't work. The error no longer pops up though.

0

Never mind that. Silly mistake. Thank you very much for the help.

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