I’m running into an error with my navigation part of my code.
I want to display an error page if a page doesn’t exist, but I’m running into an error while doing that.
local mainNav = script.Parent.Main.bottom
local expandedNav = script.Parent.Main.expanded
local menuDB = false
for i, v in ipairs(mainNav.buttons:GetChildren()) do
local frame = string.sub(v.Name, 2,100)
v.TextButton.MouseButton1Click:Connect(function()
PlaySFX()
script.Parent.Main[tostring(last)].Visible = false
last = frame
script.Parent.Main[frame].Visible = true --The error is here for the "missing" frame
if not script.Parent.Main[tostring(last)] or script.Parent.Main[frame] then --Doesn't exist
last = "Other"
script.Parent.Main.Other.Visible = true
end
-- print('"uwu" 🤓')
end)
-- print('"owo" 🤓')
end
This is because frame is just a string such as “Home” so roblox is confused, we need to first search where the frame will be for the frame itself THEN if it finds it do what you need to do