Frame Toggling Module

Hey Guys, I’m back with another Module to help ease development for people.
This Module can be used to Toggle frames On/Off.
It’s very simple to use:

Example Usage

local Frame = Container.ContainerPlay – Example Frame
local Toggler = ToggleFrame.NewFrameToggler(Frame) – Returns a “Toggler” for this Frame

Play.Activated:Connect(function()
Toggler:Toggle() – Toggles the Frame On/Off
SoundService.SFX.Click:Play() – Optional, Sound
end)

The Module

https://create.roblox.com/store/asset/105414114960064/Frame-Toggler

For Right now, I have made a simple effect when it’s toggled.
With some Tweaks and changes You can make this have Any effect when It’s toggled.

2 Likes

Why would I use this over frame.Visible = not frame.Visible? If it’s because of the tween, I may as well just make my own function.

To me, This is a bit cleaner, and This is what I would use for many frames. It’s really just your preference but is Cleaner, At least to me.

1 Like

The librarization of Luau has come, This is the left-pad of Roblox. This module is really unnecessary, you have to require a whole module which defines a function just to do something you can do natively with one line Frame.Visible = not frame.Visible

6 Likes

i suggest adding some unique features to make this standout, as others have mentioned, this can be achieved with one line, though if your looking for a cleaner alternative, you could simply wrap the line in a function, for example:

local function toggle(guiObject: GuiObject)
   guiObject.Visible = not guiObject.Visible
end

--optional variant
local function setVisibility(guiObject: GuiObject, state: boolean)
   guiObject.Visible = state
end

Next time make a “print” module which, guess what! It prints something in Roblox’s own output. That’d be cleaner!

1 Like