Menu
CoddyTech

카운트다운

Coddy의 Roblox 게임: 재난 생존 코스 레슨. 20개 중 3번째.

매 라운드가 시작되기 전에 보드에서 카운트다운을 합니다: 휴식 시간: 5, 4, 3, 2, 1. 두 가지 도구가 이 기능을 수행합니다.

함수는 작업에 이름을 붙입니다. 이 게임의 모든 메시지는 함수 하나를 거칩니다:

local function setStatus(text)
	status.Text = text
end

setStatus("Hello")

숫자 for 루프는 카운트다운을 할 수 있습니다. 세 번째 숫자는 단계이고, -1은 한 번에 하나씩 줄어듭니다. task.wait(1)은 스크립트를 1초 동안 멈추므로, 루프는 각 숫자마다 1초씩 걸립니다:

for seconds = 3, 1, -1 do
	print(seconds)
	task.wait(1)
end
print("Go!")

이 코드는 3, 2, 1을 1초 간격으로 출력한 다음 Go!를 출력합니다. 카운트다운의 길이는 Settings.Intermission에서 가져오므로, 설정을 바꾸면 게임도 바뀝니다.

challenge icon

챌린지

쉬움

라운드가 시작되기 전에 보드에 카운트다운을 표시하세요.

  1. 맨 아래에 local function setStatus(text)를 작성하여 status.Text를 설정하세요.
  2. Settings.Intermission부터 1까지 1초 간격으로 카운트다운하세요: setStatus("Intermission: " .. seconds).
  3. 반복문이 끝난 뒤 Get ready!를 표시하세요.

‘플레이’를 누르세요. 보드에 Intermission: 5부터 1까지 카운트다운한 다음 Get ready가 표시됩니다. 그런 다음 ‘확인’을 누르세요.

직접 해보기

local Players = game:GetService("Players")
local Settings = require(game.ReplicatedStorage.Settings)

print("Rounds last " .. Settings.RoundLength .. " seconds")

-- 모든 플레이어에게 리더보드의 Wins가 주어집니다
Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local wins = Instance.new("IntValue")
	wins.Name = "Wins"
	wins.Parent = leaderstats
end)

-- 로비에 있는 상태 게시판
local gui = Instance.new("SurfaceGui")
gui.Parent = workspace.StatusBoard

local status = Instance.new("TextLabel")
status.Name = "Status"
status.Size = UDim2.fromScale(1, 1)
status.BackgroundColor3 = Color3.fromRGB(25, 25, 35)
status.TextColor3 = Color3.fromRGB(255, 255, 255)
status.TextScaled = true
status.Text = "Welcome to Disaster Survival!"
status.Parent = gui

-- 레슨 3: 여기에 카운트다운이 들어갑니다

Roblox 게임: 재난 생존의 모든 레슨

직접 연습해 보세요: Roblox 플레이그라운드