I've tried so many things to get the tab switching to work but it just won't. I assume it's a simple problem with my script that I haven't noticed but I'm desperate to fix it so I can move on.
Here's my local script inside my ShopGui(Screen):
local ShopButton = script.Parent:WaitForChild("ShopButton")
local ShopFrame = script.Parent:WaitForChild("ShopFrame")
ShopButton.MouseButton1Click:Connect(function()
print("Button clicked! Toggling frame.")
ShopFrame.Visible = not ShopFrame.Visible
print("ShopFrame.Visible is now:", ShopFrame.Visible)
end)
Here's my local script inside my ShopFrame:
local tabBar = script.Parent:WaitForChild("TabBar")
local tabButtons = {
EffectsTab = tabBar:WaitForChild("EffectsTab"),
TitleTab = tabBar:WaitForChild("TitleTab"),
GamepassTab = tabBar:WaitForChild("GamepassTab"),
CoinsTab = tabBar:WaitForChild("CoinsTab"),
ItemsTab = tabBar:WaitForChild("ItemsTab"),
}
local contentFrames = {
EffectsFrame = script.Parent:WaitForChild("EffectsFrame"),
TitleFrame = script.Parent:WaitForChild("TitleFrame"),
GamepassFrame = script.Parent:WaitForChild("GamepassFrame"),
CoinsFrame = script.Parent:WaitForChild("CoinsFrame"),
ItemsFrame = script.Parent:WaitForChild("ItemsFrame"),
}
local function showFrame(frameToShow)
for _, frame in pairs(contentFrames) do
frame.Visible = false
end
frameToShow.Visible = true
end
for tabName, button in pairs(tabButtons) do
button.MouseButton1Click:Connect(function()
local frameName = tabName:gsub("Tab", "Frame")
local frameToToggle = contentFrames[frameName]
if not frameToToggle then
warn("No frame found for tab:", tabName)
return
end
if frameToToggle.Visible then
frameToToggle.Visible = false
print(frameName .. " hidden")
else
showFrame(frameToToggle)
print(frameName .. " shown")
end
end)
end
showFrame(contentFrames.ItemsFrame)