Heyo need some help with my stage selector system which looks like this
Two things to quickly note about it are
- UI Can be controlled by left and right arrow keys or mouse by hovering over the stage
- Some stages (so far just grid) have a secondary skin which you can choose if you select a stage that has one.
Ight so the issue is that I’m not exactly sure the best way to do this so it’s a bit of a mess and I just haven’t been able to get things working great so I’m looking to see if anyone could help make it less messy. I’ve provided the code that just relates to the stage selection.
--> ButtonFunctionality Module
--> Basically a module with functions for each button
module.Stage = function(StageName,Test)
local StageSkin = Main.ScreenGui.StageSelect.StageSetting
local StagesWithSkins = {"Grid"}
if table.find(StagesWithSkins,StageName) and not Test then --> Open stage skin selector
Modules.UI.CurrentFrame = StageSkin
StageSkin.Visible = true
StageSkin:TweenPosition(UDim2.new(0.001,0,0.821,0),"Out","Sine",0.4,true)
else --> Just select the stage
Main.ScreenGui.StageSelect.Visible = false
Main.ScreenGui.CharacterSelect.Visible = true
Main.Selections.Stage = StageName
end
end
--> UI Module
--> Sets up buttons and does stuff for ui
--> Function which is called when a button is pressed
function UI:ButtonPressed(Button,test)
local StageSelect = Main.ScreenGui.StageSelect
local StageSkin = StageSelect.StageSetting
local CharacterSelect = Main.ScreenGui.CharacterSelect
local TrainingSettings = Main.ScreenGui.TrainingSettings
Main.RepStorage.Sounds.ButtonSelect:Play()
if UI.CurrentFrame == StageSelect or UI.CurrentFrame == StageSkin then
Modules.UI.CurrentFrame = CharacterSelect
Modules.ButtonFunctionality["Stage"](SelectedStage,test)
end
end
--> Selecting a button by pressing Enter
elseif Input.KeyCode == Enum.KeyCode.Return then
if UI.CurrentFrame == StageSkin then
CloseFrame()
UI:ButtonPressed(nil,true)
elseif UI.CurrentFrame == StageSelect then
SelectedStage = UI.SelectedButton.Name
UI:ButtonPressed()
end
--> Selecting a button by mouse click
Button.MouseButton1Click:Connect(function()
UI:ButtonPressed(Button)
end)
The goal is to do this: Select a stage and if the stage doesn’t have an alternate form then proceed to character select, but if it does have one then open the stage skin frame to let the player select the other form and yeah.