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

Why is a TextLabel not subtracting its Transparency?

Asked by 5 years ago

I am Seisimotic and I was making a intro, just for fun, and while I was making it and testing the intro out, I realized that one of the TextLabels aren't subtracting its Transparency to be visible.

NOTE: I'm not a "God" at scripting gui's so, you may have to show me the code.

--CODE--
local click_sound = script.Parent.Parent.Parent:WaitForChild("click_sound")

script.Parent.MouseButton1Click:Connect(function()
    click_sound:Play()

    script.Parent.Visible = false
    script.Parent.Parent.skipintroButton.Visible = false
    script.Parent.Parent.TextLabel.Visible = false
    script.Parent.Parent.loadedLabel.Visible = false

    wait(2)
    while wait() do
        script.Parent.Parent.title.TextTransparency = script.Parent.Parent.title.TextTransparency - 0.01
        script.Parent.Parent.title.TextStrokeTransparency = script.Parent.Parent.title.TextStrokeTransparency - 0.01
    end

    wait(2)
    while wait() do
        script.Parent.Parent.author.TextTransparency = script.Parent.Parent.author.TextTransparency - 0.01 -- this is where it cant be subtracted.
        script.Parent.Parent.author.TextStrokeTransparency = script.Parent.Parent.author.TextStrokeTransparency - 0.01
    end

end)


1 answer

Log in to vote
0
Answered by
Rawblocky 217 Moderation Voter
5 years ago
Edited 5 years ago

You are making it repeat wait() in a loop without a stop. Replace "while wait() do" to "while script.Parent.Parent.title.TextTransparency>0 do"

I recommend using TweenService instead of adding/subtracting the transparency of the text, which will also work. It also makes the code simpler and it's much easier.

--CODE--
local click_sound = script.Parent.Parent.Parent:WaitForChild("click_sound")

script.Parent.MouseButton1Click:Connect(function()
    click_sound:Play()

    script.Parent.Visible = false
    script.Parent.Parent.skipintroButton.Visible = false
    script.Parent.Parent.TextLabel.Visible = false
    script.Parent.Parent.loadedLabel.Visible = false

    wait(2)
game:GetService('TweenService'):Create(script.Parent.Parent.title,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0),{TextTransparency=0,TextStrokeTransparency=0}):Play()

    wait(2)
game:GetService('TweenService'):Create(script.Parent.Parent.author,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0),{TextTransparency=0,TextStrokeTransparency=0}):Play()

end)

[the 1 in TweenInfo.new(1,Enum.EasingStyle is the amount of seconds of how long the tweening is] [by the way if the text gets cutted up hover over the code and click "view source"]

Ad

Answer this question