I have a shop where if the player enters its radius it will trigger a cutscene/transition. The camera just moves to a spot inside of the building, input is ignored, and a menu is opened. The issue I have is I can’t figure out how to set things back to normal the only way to exit is to press the leave button, but my current code is kind of a mess so it’s been kind of difficult to achieve that haha.
This is the shop code that opens the menu and starts the cutscene/transition when the player enters its radius
CustomizationStation.enterCustomizationStation = FastSignal.new()
function CustomizationStation.new(part)
local self = setmetatable(Interactable.new(),CustomizationStation)
self.cameraSpotsFolder = part.Parent.CameraSpots
self.model = part.Parent.Model
self.command = OpenMenuCommand.new(1)
return self
end
function CustomizationStation:triggerEntered()
self.command:execute()
CustomizationStation.enterCustomizationStation:Fire(self)
end
return CustomizationStation
I’m trying to make use of a state machine for my character and I feel like this is actually what’s making things difficult.
function State.new(characterModule)
local self = setmetatable({},State)
self.characterModule = characterModule
self.inputModule = characterModule.input
self.shouldStartCutscene = false
self.shouldEndCutscene = false
self.states = FSM.create({
initial = "Neutral",
events = {
{name = "Neutral", from = "*", to = "Neutral"},
{name = "Jump", from = "Neutral", to = "Jump"},
{name = "Land", from = "Jump", to = "Neutral"},
{name = "LaunchingBey", from = "Neutral", to = "Battling"},
{name = "RecallingBey", from = "Battling", to = "Neutral"},
{name = "Battling", from = "LaunchingBey", to = "Battling"},
{name = "Cutscene", from = "*", to = "Cutscene"},
},
})
RunService:BindToRenderStep(renderName,renderPriority,function()
self:update()
end)
CustomizationStation.enterCustomizationStation:Connect(function(obj)
local startingCameraSpot = obj.cameraSpotsFolder.Bey
self.characterModule.camera:setCameraFocus(startingCameraSpot)
self:startCutscene()
end)
return self
end
function State:startCutscene()
self.shouldStartCutscene = true
end
function State:endCutscene()
self.shouldEndCutscene = true
end
function State:update()
if self.shouldStartCutscene and not self.states:is("Cutscene") then
self.states:Cutscene()
self.shouldStartCutscene = false
end
if self.shouldEndCutscene and self.states:is("Cutscene") then
self.states:Neutral()
self.shouldEndCutscene = false
end
end
And then this is in my UI code I only have one button at the moment so I just hard coded it here it closes the menu, but as you can see there’s no real clean way for me to go out of the cutscene state once the player is in it.
local function SetupButton(button)
button.MouseEnter:Connect(function()
end)
button.MouseLeave:Connect(function()
end)
button.MouseButton1Click:Connect(function()
local CloseMenuCommand = require(modules.Commands.CloseMenuCommand)
CloseMenuCommand.new():execute()
end)
end