Hello Guys!
I need help with fixing some Debounce on this module script:
--//Services
local TS = game:GetService("TweenService")
local LS = game:GetService("Lighting")
--//Lighting
local GuiBlur = LS.GuiBlur
--//Variables
--Tweening
local OpenInfo = TweenInfo.new(0.25, Enum.EasingStyle.Quint, Enum.EasingDirection.In)
local CloseInfo = TweenInfo.new(0.25, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
--//Module Functions
local Functions = {}
local CurrentOpenedFrame = {
MFrame = nil,
OpenPosition = nil,
ClosePosition = nil,
CustomEnterInfo = nil,
CustomExitInfo = nil,
}
local ToggleStatus = {}
local Debounces = {}
function Functions.OpenMFrame(MFrame, OpenPosition, ClosePosition, CustomEnterInfo, CustomExitInfo)
if Debounces[MFrame] == nil then
Debounces[MFrame] = true
if CustomEnterInfo == nil then
CustomEnterInfo = OpenInfo
end
if CustomExitInfo == nil then
CustomExitInfo = CloseInfo
end
if CurrentOpenedFrame.MFrame ~= nil then
Functions.CloseMFrame(CurrentOpenedFrame.MFrame, CurrentOpenedFrame.ClosePosition)
end
local PositionalTween = TS:Create(MFrame, CustomEnterInfo, {Position = OpenPosition})
local BlurTween = TS:Create(GuiBlur, CustomEnterInfo, {Size = 56})
MFrame.Visible = true
local ScreenGui = MFrame:FindFirstAncestorWhichIsA("ScreenGui")
ScreenGui.DisplayOrder += 1
PositionalTween:Play()
BlurTween:Play()
BlurTween.Completed:Wait()
CurrentOpenedFrame.MFrame = MFrame
CurrentOpenedFrame.OpenPosition = OpenPosition
CurrentOpenedFrame.ClosePosition = ClosePosition
CurrentOpenedFrame.CustomEnterInfo = CustomEnterInfo
CurrentOpenedFrame.CustomExitInfo = CustomExitInfo
Debounces[MFrame] = nil
ToggleStatus[MFrame] = true
end
end
function Functions.CloseMFrame(MFrame)
if Debounces[MFrame] == nil then
Debounces[MFrame] = true
local PositionalTween = TS:Create(MFrame, CurrentOpenedFrame.CustomExitInfo, {Position = CurrentOpenedFrame.ClosePosition})
local BlurTween = TS:Create(GuiBlur, CurrentOpenedFrame.CustomExitInfo, {Size = 0})
local ScreenGui = MFrame:FindFirstAncestorWhichIsA("ScreenGui")
ScreenGui.DisplayOrder -= 1
PositionalTween:Play()
BlurTween:Play()
task.spawn(function()
BlurTween.Completed:Wait()
CurrentOpenedFrame.MFrame = nil
CurrentOpenedFrame.OpenPosition = nil
CurrentOpenedFrame.ClosePosition = nil
CurrentOpenedFrame.CustomEnterInfo = nil
CurrentOpenedFrame.CustomExitInfo = nil
MFrame.Visible = false
Debounces[MFrame] = nil
ToggleStatus[MFrame] = nil
end)
end
end
function Functions.ToggleMFrame(MFrame, OpenPosition, ClosePosition, CustomEnterInfo, CustomExitInfo)
if ToggleStatus[MFrame] == nil then
Functions.OpenMFrame(MFrame, OpenPosition, ClosePosition, CustomEnterInfo, CustomExitInfo)
return ToggleStatus[MFrame]
elseif ToggleStatus[MFrame] == true then
Functions.CloseMFrame(MFrame)
return ToggleStatus[MFrame]
end
end
return Functions
This Module script handles toggling the Main Frames of each gui. The Debounces Table handles actual gui debounces. The ToggleStatus Table handles if to open or close.
Now I was trying to see if this can sustain very fast switching between Guis, and sadly it broke with this error:
And it breaks it permanently and pops 2 Guis:
Here is a video if you want more details of the error: External Media
Sadly idk what is happening here. How can I fix this?
Thanks for stopping by!