Guys, I need help with something.
Here’s my current file structure:
- ReplicatedStorage
- Library
- Interface
- Components
- Buttons
- MenuButton
- Panels
- Episodes
- Buttons
- Screens
- Components
- Interface
- Library
- StarterPlayer
- StarterPlayerScripts
- UISetup
- StarterPlayerScripts
I’m handling my UI components using Fusion. I have a template menu button and have an Episodes panel. I handle my all my UI components using the UISetup script in StarterPlayerScripts. I loop over the Panels folder and parent the component the module script returns and parent them to the menu screen.
I can’t think of a way to create the MenuButton in such a way where it will have a system of binding a panel. That’s the basic idea.
Right now, here’s my code to handle the ui components (Component.luau):
No need to tell me that the current code doesn’t work, it’s still wip
--!strict
-- // Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- // Folders
local Packages = ReplicatedStorage.Packages
-- // Dependencies
local Fusion = require(Packages.Fusion)
local Library = require(ReplicatedStorage.Library)
local Messages = Library.Config.Messages
-- // Variables
local CS = {} -- Component System
-- // Modification
-- // Functions
function CS.Build(
class: "Panel" | "Button",
states: (Value: any) -> { [any]: Fusion.StateObject<any> },
component: (fusion: any, states: {}) -> Instance
): {
Class: "Button" | "Panel",
States: {},
Component: Instance,
Binded: {}?,
}
if class == "Panel" then
print("what did i do")
elseif class == "Button" then
local BindedComponent
function Bind(class: { [any]: any })
if typeof(class) == "table" and class.Class == "Panel" then
BindedComponent = class
end
end
return {
Class = "Button",
Component = component(Fusion, states(Fusion.Value)) :: Instance,
Bind = Bind,
Binded = BindedComponent,
}
else
Messages.Warn("InvalidClass", "Button, Panel")
return nil
end
end
-- // Event Listeners
-- // Returning
return CS