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

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

[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

2 comments

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.

0

Okay.

2 answers

✓ Accepted answer

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

for i,v in ipairs(btonFrameCombos) do

It should be btnFrameCombos, not btonFrameCombos

3 comments

1

Remove the edits suggested by coltn5000 and return to your original code. Fix the name of btnFrameCombos and you will be set.

0

Thanks so much! Again! :)

1

Glad to help :)

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

1 comment

0

Okay, I edited the post (I was a little confused) Please check it out.

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