#Shop Script Gui Problems

1 messages · Page 1 of 1 (latest)

tawny mountain
#

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)

pseudo forge
#

Oh, wait

#

you have it looking for "TabBar" without a space, but your tab bar object has a space in the game

tawny mountain
pseudo forge
#

I wish you luck with finding the solution, though

tawny mountain
pseudo forge
#

Isn't scripting just so lovely

tawny mountain