I don’t think this will work for my UI. Will it?
The UI:
I will still try it.
Well the example I gave worked exactly like a website (you could even add the back and forward buttons) so it will work.
This method works with more than one button leading to different things per page as well, meaning that everything in your gui should work. If you have a button that you don’t want to swap the page just don’t put it into the pagebuttons folder.
Do you mean like having the folders is not compulsory?
I would recommend using UIPageLayout
this way you can loop through all the menu buttons and give the Activated connection and then use :JumpTo()
to go the corresponding page.
-- Local script (just one is needed)
local MenuButtons = -- Define here
local Pages = -- Define here
local UIPageLayout = --Define here (should be in the Pages frame)
for _, button in pairs(MenuButtons:GetChildren()) do
if button:IsA("ImageButton") then
button.Activated:Connect(function()
-- This will only work if the page is the same name as the button
UIPageLayout:JumpTo(Pages:FindFirstChild(button.Name))
end
end
end
Uhmm. I don’t think I understood that. Do you mean to add UIPageLayout
to all the Frames I am using as a page. I did’t get what the :JumpTo()
thing means
So create a frame to fill up the right side of your UI and make it invisible (wherever your pages are going to go) and insert a UIPageLayout and then drag all your pages as a child of the invisible frame.
Will it work if the button and the page are in a different frame?
Yeah assuming the buttons are all together as well
Yes they are in the same page.
Edit: I meant frame.
If you can send me a screenshot of how your explorer looks I can help guide you on what to do, If you feel like everything is already in place then you can simple use the script I wrote earlier
Can you send an image of your explorer so I can see how you have it laid out? Also for this, I would recommend making an invisible frame or white frame and using that as the background so it takes up the whole area under the top bar. Now call that frame “Pages” and put all the pages in there. Then make another frame invisible or grey and set that up so its the same size as the sidebar and make sure that is on top of the pages frame so when you open the menu it’s in front of the page UI and call this frame “Menu” or “Sidebar” now use a UIlistlayout so it’s all neat and you can mess around with the padding etc.
This is what I mean visually:
So the red would be a white frame called pages and the blue frame would the be menu frame.
Yes, tho the blue frame is called Sidebar
and the main frame is called MainFrame
Yeah it’s fine, I thought I’d call it pages since it makes more sense but as long as you know where things are you should be good!
Have to add the LocalScript
in Sidebar
right?
Can you show me your full explorer so I can see? You can have the script anywhere in the UI as long as you define everything correctly
Sorry for the late reply. So I’m assuming the HomeScreen is where your UIPageLayout is going to go. Also by the looks of things you have many local scripts already so you can just add the code I sent a couple of replies back into one of them or create a new one. I would recommend having it in the menu script. Hopefully, that helps but Yeah everything should be good already. Just adapt the script to match your layout and it should work.
Thanks for your help. Appreciate it.