루아(LUA)/로블록스

텍스트 레이블 카운트 다운[1일 1코딩 #1]

JK77 2022. 1. 19. 07:39

텍스트 레이블 타임

-- Place this code in a LocalScript within a TextLabel/TextButton
local textLabel = script.Parent

-- Some colors we'll use with TextColor3
local colorNormal = Color3.new(0, 0, 0) -- black
local colorSoon = Color3.new(1, .5, .5) -- red
local colorDone = Color3.new(.5, 1, .5) -- green

-- Loop infinitely
while true do
	-- Count backwards from 10 to 1
	for i = 10, 1, -1 do
		-- Set the text
		textLabel.Text = "Time: " .. i
		-- Set the color based on how much time is left
		if i > 3 then
			textLabel.TextColor3 = colorNormal
		else
			textLabel.TextColor3 = colorSoon
		end
		wait(1)
	end
	textLabel.Text = "GO!"
	textLabel.TextColor3 = colorDone
	wait(2)
end