So I have a :GetPropertyChangedSignal
in my game, the property it is tracking is the visible property for GuiObjects, Now, problem is that I change the visible property after the signal is fired, which makes it go in an infinite loop, Idk if this is normal (I thought I saw somewhere it isnt)
If not, how can I work around this? Its kinda annoying (it crashes the whole game)
local function VisibleChanged(Frame:Frame)
local Info = UIStorage:Find(Frame)
if not Info then
Info = {
Size = Frame.Size,
Position = Frame.Position,
}
Info = UIStorage:Store(Frame,Info)
end
local Visible = Frame.Visible
if Visible then
Frame.Visible = false
Frame.Size = UDim2.new(0,0,Frame.Size.Y.Scale,Frame.Size.Y.Offset)
local Tween = TweenService:Create(Frame,OpenAnimationInfo,Info.Item.Size)
Frame.Visible = true
Tween:Play(); Tween.Completed:Wait(); Tween:Destroy()
else
Frame.Visible = true
local Size = UDim2.new(0,0,Frame.Size.Y.Scale,Frame.Size.Y.Offset)
local Tween = TweenService:Create(Frame,OpenAnimationInfo,Size)
Tween:Play(); Tween.Completed:Wait(); Tween:Destroy(); Frame.Visible = false
end
end
-- // Main //
function Module:SetUI(PassedUI:ScreenGui)
UI = PassedUI
for _, Frame:Frame in UI:GetDescendants() do
if Frame:GetAttribute(AnimKey) ~= nil and Module.AnimsEnabled then
print('Enabled')
Frame:GetPropertyChangedSignal('Visible'):Connect(VisibleChanged,Frame)
end
end
UI.DescendantAdded:Connect(function(Frame:Frame)
if Frame:GetAttribute(AnimKey) ~= nil and Module.AnimsEnabled then
Frame:GetPropertyChangedSignal('Visible'):Connect(VisibleChanged,Frame)
end
end)
end