#Optimize code?

1 messages · Page 1 of 1 (latest)

thin cloak
#

So I have a local script that connects to a module that handles the tweening, was just wondering if there's a better way to implement this code. I am yet to add a module loader, names right now is kind of a mess since I'm just trying to see if this gui script works throughout.

#

LocalScript

local button_PLAY = script.Parent.Frame.PLAY_BUTTON
local menu_FRAME = script.Parent
local menu_FRAME_CONT = menu_FRAME.Frame
local tween_MOD = require(game.StarterPlayer.StarterPlayerScripts:WaitForChild('LOCAL_TWEEN'))

button_PLAY.MouseButton1Click:Connect(function()
    local currentPos = menu_FRAME_CONT.Position
    local tr_SETTING = {
        TextTransparency = 1
    }
    local pos_TABLE = {
        Position = UDim2.new(
            currentPos.X.Scale -1,
            currentPos.X.Offset,
            currentPos.Y.Scale,
            currentPos.Y.Offset
        )
    }
    tween_MOD.GUItween(menu_FRAME_CONT, .75, 'Quad', 'In', 0, false, 0, tr_SETTING, true)
    task.wait(.5)
    tween_MOD.GUItween(menu_FRAME, 1, 'Quad', 'In', 0, false, 0, pos_TABLE, false)
end)

button_PLAY.MouseEnter:Connect(function()
    
end)```
#

Module Script

local LOCAL_TWEEN = {}
local tween_SERVICE = game:GetService('TweenService')

function LOCAL_TWEEN.GUItween(tg_DIR, t_time, tstyle, tdir, trep, trev, tdel, tgoal, cc)
    local tween_INFO = TweenInfo.new(
        t_time,
        Enum.EasingStyle[tstyle],
        Enum.EasingDirection[tdir],
        trep,
        trev,
        tdel
    )
    if cc then
        for _, m in ipairs(tg_DIR:GetChildren()) do
            if m:IsA('GuiObject') then
                local tween = tween_SERVICE:Create(m, tween_INFO, tgoal)
                tween:Play()
            end
        end
    else
        local tween = tween_SERVICE:Create(tg_DIR, tween_INFO, tgoal)
        tween:Play()
    end
end
return LOCAL_TWEEN```
white tulip
#

its fine

unique dawn
#

what style guide is this guy using😭