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

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

Asked by 7 years ago

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)

0
Try to use WaitForChild. TheHospitalDev 1134 — 7y

1 answer

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

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)
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. Sniper2458 11 — 7y
0
Never mind that. Silly mistake. Thank you very much for the help. Sniper2458 11 — 7y
Ad

Answer this question