Any way on how to make my script shorter?

THANK YOU VERY VERY MUCH!! Thank you so much1

1 Like

Your welcome!
I’m kinda busy now, when I’m free, I’ll point out your mistakes so you can learn from them.

@7yooso explain for i,v loop to this guy

lol fr :sob: minimum characters required

hey i know it is already solved, but it could use A LOT of optimizations, heres what i came up with:

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local TweenService = game:GetService("TweenService")

local content, isReady = Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)

local WelcomeFrame = script.Parent.WelcomeFrame
local HomeBTN = WelcomeFrame.HomeBTN
local Logo = WelcomeFrame.Logo
local thing = WelcomeFrame.Thing
local lang = WelcomeFrame.Language
local Name = WelcomeFrame.plrname
local icon = WelcomeFrame.Plricon

local homefram = script.Parent.HomeFrame
local CheckBTN = homefram.CheckBTN
local FiBTN = homefram.FiBTN
local logos = homefram.Logo

local backgrounds = {
    {homefram.BackGround2, homefram.BackGround2.es, homefram.BackGround2.descp},
    {homefram.BackGround, homefram.BackGround.es, homefram.BackGround.Descp}
}

local camera = workspace.CurrentCamera
local looking = false
local endCFrame = CFrame.new(game.Workspace.test.Position)

local tweentime = 2
local debouncetime = 0.5
local active = false

local event = game.ReplicatedStorage.test
event.OnClientEvent:Connect(function(plr)
    if active then return end
    active = true
    looking = not looking

    if looking then
        camera.CameraType = Enum.CameraType.Scriptable
        TweenService:Create(camera, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {CFrame = endCFrame}):Play()
        wait(tweentime + debouncetime)
    else
        camera.CameraType = Enum.CameraType.Custom
        wait(debouncetime)
    end

    active = false
end)

local function createTweens(elements, tweenInfo)
    local tweens = {}
    for _, element in pairs(elements) do
        local tween = TweenService:Create(element[1], tweenInfo, element[2])
        table.insert(tweens, tween)
    end
    return tweens
end

local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local tweenInfo2 = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

local initialTweens = {
    {Logo, {ImageTransparency = 1}},
    {thing, {ImageTransparency = 1}},
    {lang, {TextTransparency = 1}},
    {Name, {TextTransparency = 1}},
    {HomeBTN, {TextTransparency = 1}},
    {icon, {ImageTransparency = 1, BackgroundTransparency = 1}},
}

local logoTweens = {
    {logos, {ImageTransparency = 0}},
    {homefram.BackGround, {ImageTransparency = 0}},
    {homefram.BackGround2, {ImageTransparency = 0}},
}

for _, bg in ipairs(backgrounds) do
    table.insert(logoTweens, {bg[1], {TextTransparency = 0}})
    table.insert(logoTweens, {bg[2], {TextTransparency = 0}})
end

local initialTweenObjects = createTweens(initialTweens, tweenInfo)
local logoTweenObjects = createTweens(logoTweens, tweenInfo)

icon.Image = content
Name.Text = player.Name

local function onMouseEnterExit(button, enterTweens, exitTweens)
    button.MouseEnter:Connect(function()
        for _, tween in ipairs(enterTweens) do tween:Play() end
    end)
    button.MouseLeave:Connect(function()
        for _, tween in ipairs(exitTweens) do tween:Play() end
    end)
end

onMouseEnterExit(CheckBTN, {tweens.cool4, tweens.verycool3}, {tweens.cool2, tweens.verycool})
onMouseEnterExit(FiBTN, {tweens.cool3, tweens.veryco