This is a script that opens one of my main GUIs when a button is clicked or C is pressed. It was working fine but recently i just tried to add another frame like i've done before and when I did it broke the script and there is no error message. If I even change the name of a frame that this script references the script messes up. I've been trying to troubleshoot it and found the problem resides in the "for index, child in pairs(CGUI) do" block because when I remove that part the script works again. Anyone have any ideas? I'm thinking it was something outside of this script that I did because I haven't changed this script between when it was working and when it broke. Thanks!
wait(3) local BUTTON = script.Parent function onMouseButton1Down(mouse) local BUTTON = script.Parent local SFRAME = BUTTON.Parent.SelectFrame local CGUI = BUTTON.Parent:GetChildren() for index, child in pairs(CGUI) do child:WaitForChild(child) if child.Name ~= "Craft" and child ~= SFRAME then child.Visible = false SFRAME.Visible = (not SFRAME.Visible) end end end Player = game.Players.LocalPlayer Mouse = Player:GetMouse() function PressedC(key) local BUTTON = script.Parent local SFRAME = BUTTON.Parent.SelectFrame local Key = key:lower() local CGUI = BUTTON.Parent:GetChildren() if Key == "c" then for index, child in pairs(CGUI) do if child.Name ~= "Craft" and child ~= SFRAME then child.Visible = false SFRAME.Visible = (not SFRAME.Visible) end end end end Mouse.KeyDown:connect(PressedC) BUTTON.MouseButton1Down:connect(onMouseButton1Down)