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

Why is this script not going through all of its lines?

Asked by 8 years ago
Edited 8 years ago

I have a script here that basically is a intro, There is this one part of it that is suppose to have its transparency go from 1 to 0, But after it goes from 1 to 0 it doesn't go through its lines, From a previous question I asked I assumed it is because I didn't lower the transparency correctly so here is the script:

local textLabel = Instance.new("TextLabel")
textLabel.Parent = screenGui
textLabel.Position = UDim2.new(0, 700, 0, 350)
textLabel.Size = UDim2.new(0, 150, 0, 50)
textLabel.BackgroundColor3 = BrickColor.White().Color
textLabel.Text = "Roogle"
textLabel.Font = "Legacy"
textLabel.FontSize = 14
textLabel.BackgroundTransparency = 1
textLabel.TextColor3 = BrickColor.Red().Color
a = 1
 repeat
    textLabel.TextTransparency = a
    wait (0.01)
    a = a-0.01
until textLabel.TextTransparency == 0

wait (3)
textLabel:Destroy()

At the Roogle part is where the transparency goes to 0 but doesn't delete itself, A previous question I asked about making the FontSize go up he gave me this

for i, v in ipairs(Enum.FontSize:GetEnumItems()) do
    print(v.Name)
    textLabel.FontSize = v
    wait(0.001) -- You may find that this is too small.
    if v == Enum.FontSize.Size14 then break end
end

Before you tell me it is a FontSizenot Transparency I did change everything to Transparency Enum.TextTransparency.Size0 and all of that but it still didn't work, It didn't tell me anything in the system, It didn't tell me anything was wrong so I can't help you guys there.

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

It probably has something to do with precision or floating point numbers

Just do it the regular way with a for loop.

for i = 1,0,-0.01 do
    textLabel.TextTransparency = i
    wait()
end

That's the regular way of doing it, but to avoid floating point problems you can use whole numbers and divide properly to get the decimal.

for i = 100,0,-1 do
    textLabel.TextTransparency = i/100
    wait()
end

Whole script

This is what the script looks like now,

local textLabel = Instance.new("TextLabel")
textLabel.Parent = screenGui
textLabel.Position = UDim2.new(0, 700, 0, 350)
textLabel.Size = UDim2.new(0, 150, 0, 50)
textLabel.BackgroundColor3 = BrickColor.White().Color
textLabel.Text = "Roogle"
textLabel.Font = "Legacy"
textLabel.FontSize = 14
textLabel.BackgroundTransparency = 1
textLabel.TextColor3 = BrickColor.Red().Color

for i = 100,0,-1 do
    textLabel.TextTransparency = i/100
    wait()
end

wait (3)
textLabel:Destroy()

Good Luck!

If I helped, please don't forget to accept my answer.
Ad

Answer this question