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

[ SOLVED By AxeOfMen ] How should I fix this gui function? [closed]

Asked by 10 years ago

[Solved]

The button functions in the script is where it is broken, but I don't know what is wrong with it? Everything is named correctly..

This is what it should do... When you press one button, it closes all the other frames and only one frame should be visible (The frame linked to the button.)

How should I fix this and what is the problem?


--Club RoBeats Menu --IntellectualBeing --3/24/2014 ----------------------------------------------------------------- -----------[Main Variable Parents]----------- local Core = script --LOL local Main = script.Parent --The Mega Parent (Holds everything) local OpenM = script.Parent.OpenMenu --Button Frame local OpenB = OpenM.Open --Open Button local Content = script.Parent.MenuContent --Holds all the stuff local MenuTitle = script.Parent.Title --Pointless to have as a variable but okay. --[Player Variables]-- ----------------------------------------------------------------- --Open Menu + A tween! Left to right going fast to slow then do it in reverse when closing. --Button Functions local btnFrameCombos = { { button = Content:FindFirstChild("About"), frame = Content:FindFirstChild("AboutPage") }, { button = Content:FindFirstChild("Settings"), frame = Content:FindFirstChild("SettingsPage") }, { button = Content:FindFirstChild("Staff"), frame = Content:FindFirstChild("StaffPage") }, { button = Content:FindFirstChild("Inventory"), frame = Content:FindFirstChild("InventoryPage") }, { button = Content:FindFirstChild("Updates"), frame = Content:FindFirstChild("UpdatesPage") }, { button = Content:FindFirstChild("Songs"), frame = Content:FindFirstChild("SongsPage") }, { button = Content:FindFirstChild("Donate"), frame = Content:FindFirstChild("DonatePage") }, } local function showFrame(frame) for i,v in ipairs(btnFrameCombos) do v.frame.Visible = v.frame == frame end end for i,v in ipairs(btnFrameCombos) do v.button.MouseButton1Click:connect(function() showFrame(v.frame) end) end
1
@IntellectualBeing, there is nothing wrong with this code: "v.frame.Visible = v.frame == frame" - What that does is evaluate whether v.frame is frame. That evaluation results in a bool value which gets assigned to the Visible property of the current frame. AxeOfMen 434 — 10y
0
Okay. IntellectualBeing 430 — 10y

Locked by MrNicNac

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
AxeOfMen 434 Moderation Voter
10 years ago

The problem is here (Line 65 of your original code):

for i,v in ipairs(btonFrameCombos) do

It should be btnFrameCombos, not btonFrameCombos

1
Remove the edits suggested by coltn5000 and return to your original code. Fix the name of btnFrameCombos and you will be set. AxeOfMen 434 — 10y
0
Thanks so much! Again! :) IntellectualBeing 430 — 10y
1
Glad to help :) AxeOfMen 434 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Just to remind you v.frame.Visible is a boolean not an objectValue instead of doing v.frame.Visible = v.Frame do this v.frame.Visible = true then copy the HideFrame() function down below

    function HideFrame()
        for i, v in ipairs(btnFrameCombos) do
            if v:IsA("Frame") then
            v.Visible = false
            end
        end
    end

    for i,v in ipairs(btonFrameCombos) do
        v.button.MouseButton1Click:connect(function()
        HideFrame()
        showFrame(v.frame)
        end)
    end

0
Okay, I edited the post (I was a little confused) Please check it out. IntellectualBeing 430 — 10y