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

How can I shorten script and have it still work?

Asked by 2 years ago

Ive tried a lot of ways but only one works, im new to scripting so can someone help?

local part = game.Workspace.Fade1
local q = script.Parent.q
local w = script.Parent.w
local e = script.Parent.e
local r = script.Parent.r
local t = script.Parent.t
local y = script.Parent.y
local u = script.Parent.u
local i = script.Parent.i
local o = script.Parent.o

local black = script.Parent

local function faded()


    black.Transparency = black.Transparency - 0.05
    wait(0.1)
    black.Transparency = black.Transparency - 0.05
    wait(0.1)
    black.Transparency = black.Transparency - 0.05
    wait(0.1)
    black.Transparency = black.Transparency - 0.05
    wait(0.1)
    black.Transparency = black.Transparency - 0.05
    wait(0.1)
    black.Transparency = black.Transparency - 0.05
    wait(0.1)
    black.Transparency = black.Transparency - 0.05
    wait(0.1)
    black.Transparency = black.Transparency - 0.05
    wait(0.1)
    black.Transparency = black.Transparency - 0.05
    wait(0.1)
    black.Transparency = black.Transparency - 0.05
    wait()
    black.Transparency = 0



    wait(0.45)

    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.05)
    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.05)
    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.05)
    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.05)
    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.05)
    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.05)
    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.05)
    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.05)
    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.05)
    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.05)
    q.TextTransparency = q.TextTransparency - 0.05
    wait(0.5)
    --the rest of the letters go here
    wait(1.5)

    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    q.TextTransparency = q.TextTransparency + 0.05
    wait(0.025)
    --rest goes here 


    wait(0.5)
    black.Transparency = black.Transparency + 0.05
    wait(0.1)
    black.Transparency = black.Transparency + 0.05
    wait(0.1)
    black.Transparency = black.Transparency + 0.05
    wait(0.1)
    black.Transparency = black.Transparency + 0.05
    wait(0.1)
    black.Transparency = black.Transparency + 0.05
    wait(0.1)
    black.Transparency = black.Transparency + 0.05
    wait(0.1)
    black.Transparency = black.Transparency + 0.05
    wait(0.1)
    black.Transparency = black.Transparency + 0.05
    wait(0.1)
    black.Transparency = black.Transparency + 0.05
    wait(0.1)
    black.Transparency = black.Transparency + 0.05

    black.Transparency = 1



end

part.Touched:Connect(faded)

1 answer

Log in to vote
1
Answered by 2 years ago

hey! instead of repeating that one line a bunch, u can do this:

for i = 1,10 do 
    black.Transparency = black.Transparency - 0.05
    wait(0.1)
end

and the same for the other repeats-- this will repeat the line for as many times listed in the 'for i - 1,10' section

Ad

Answer this question