Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is a TextLabel not subtracting its Transparency?

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

✓ Accepted answer

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"]

This discussion is preserved as it was. New answers, comments, and votes are closed.