Why doesn't this change the ImageTransparency?

local countdown = script.Parent.Parent.countdown
local seconds = 5

for x = seconds, 1, -1 do
	countdown.Text = "Please wait "..x.." seconds"
	wait(1)
	if countdown.Text == "Please wait 2 seconds" then
		countdown.Text = "Please wait 1 second"
		wait(1)
		countdown.Text = "Please click the button above to continue"
		break
	end
end

while wait(15) do
	if countdown.Text == "Please click the button above to continue" then
		for i = .6, 0, -.05 do
			local button = script.Parent.Parent.agreeButton.TextButton_Roundify_15px.ImageTransparency
			button = i
			if button == 0 then
				break
			end
		end
	end
end

Title says it all, don’t know what I’ve messed up. Top part of the screen works just fine, the bottom one is the thing that doesn’t work.

Found out why. Screenshot by Lightshot

There’s a better way to write out your loop over misusing the break condition, by the way.

for x = seconds, 0, -1 do
    if x <= 0 then
        countdown.Text = "Click the button above to continue"
    else
        countdown.Text = ("Please wait %i %s"):format(x, x == 1 and "second" or "seconds")
       wait(1)
    end
end

You’re essentially waiting that on extra second so we take advantage of it to put the closing remark. The loop terminates afterward because it has no more iterations to run through and it’s immediate due to a lack of a wait. In the case that the timer is not 0, we just format the text accordingly and then sleep the thread for one second.

2 Likes