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

Can anyone find why adding a single frame breaks this script?

Asked by 7 years ago

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)
0
You could probably just make the simple script and copy and paste it to every gui you need it to.. H4X0MSYT 536 — 7y
0
Why do you require 2 functions to accomplish this? It's unnecessary, and you only require one function (I say this from experience, btw. :P). And from the looks of your script, there's an error on line 12, as the WaitForChild will be looking for the child w/in the child lol. Ah well, we're only human after all. :) TheeDeathCaster 2368 — 7y
0
Yeah the first part of line 12 that you're referring to was just something i tried adding to fix the script and forgot to take it out. How would you combine those two functions though? doesn't seem possible Gwolflover 80 — 7y

Answer this question