Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make an object (Frame, TextLabel, etc.) Tween out from both of its sides?

Asked by 9 years ago

For this "Level Up!" Gui, I'm trying to make it so an object tweens out from both sides under the "Level Up!" TextLabel. My script is below, just incase anyone wanted to see it to change my formula.

local plr = game.Players.LocalPlayer
repeat wait() until plr and plr.Character
local experience = plr.Data.EXP
local level = plr.Data.Level
local levels = script.Parent.Parent.Parent.Frame.Level.Level
local LevelUp = script.Parent.Parent.Parent.Parent.LevelUp
local TextLabel = LevelUp.Parent.TextLabel
local maxexp = level.Value * 500
local maxlevel = 5
script.Parent.Text = "EXP: " ..experience.Value.. "/" ..maxexp
levels.Text = level.Value
experience.Changed:connect(function()
    if experience.Value <= maxexp + 1 then
        script.Parent.Text = "EXP: " ..experience.Value.. "/" ..maxexp
        levels.Text = level.Value
    end
    if experience.Value >= maxexp or experience.Value == maxexp then
        level.Value = level.Value + 1
        levels.Text = level.Value
        TextLabel:TweenSizeAndPosition((UDim2.new(0, 600, 0, 3)), (UDim2.new(0.3, 0, 0.4, 0)), "Out", "Quart", 0.5, false, nil)
        wait(0.1)
        LevelUp:TweenPosition(UDim2.new(0.3, 0, 0.35, 0), "Out", "Quart", 0.3, false, nil)
        for i = 1, 10 do
            wait(0.01)
            LevelUp.TextTransparency = LevelUp.TextTransparency - 0.1
        end
        wait(2)
        TextLabel:TweenSizeAndPosition((UDim2.new(0, 0, 0, 3)), (UDim2.new(0.3, 0, 0.4, 0)), "Out", "Quart", 0.5, false, nil)
        for i = 1, 5 do
            wait()
            LevelUp.TextTransparency = LevelUp.TextTransparency + 0.2
            LevelUp.Position = LevelUp.Position + UDim2.new(0, 0, 0.0025, 0)
        end
        maxexp = level.Value * 500
        experience.Value = 0
        script.Parent.Text = "EXP: " ..experience.Value.. "/" ..maxexp 
    end
    while level.Value == maxlevel or level.Value >= maxlevel do
        wait()
        level.Value = maxlevel
        experience = 0
    end
end)
level.Changed:connect(function()
    wait()
    levels.Text = level.Value
    maxexp = level.Value * 500
    experience.Value = experience.Value - experience.Value
    script.Parent.Text = "EXP: " ..experience.Value.. "/" ..maxexp
    if experience.Value >= maxexp or experience.Value == maxexp then
        experience.Value = 0
        while wait() do
            script.Parent.Text = "EXP: " ..experience.Value.. "/" ..maxexp
        end
    end
    while level.Value == maxlevel or level.Value >= maxlevel do
        wait()
        level.Value = maxlevel
        experience = 0
    end
end)

Answer this question