Menu
CoddyTech

게임판

Coddy의 Roblox 게임: 끝없는 타워 코스 레슨. 21개 중 12번째.

obby는 라운드 방식으로 진행됩니다. 로비에서 잠시 기다린 다음, 새로운 타워가 나타나고 정상까지 경주합니다. 플레이어는 무슨 일이 일어나고 있는지 알아야 하므로, 로비에는 스폰 지점을 바라보는 평평한 파트인 Board가 있습니다.

파트 위의 텍스트는 SurfaceGui를 사용하며, 그 안에 TextLabel이 있습니다. UDim2.fromScale(1, 1)은 레이블이 면 전체를 채우게 하고, TextScaled는 텍스트가 맞도록 크기를 조정합니다.

local gui = Instance.new("SurfaceGui")
gui.Parent = workspace.Lobby.Board

local boardLabel = Instance.new("TextLabel")
boardLabel.Size = UDim2.fromScale(1, 1)
boardLabel.TextScaled = true
boardLabel.Text = "Endless Tower"
boardLabel.Parent = gui

카운트다운은 1초마다 기다리면서 -1씩 거꾸로 세는 for 루프입니다.

for i = 3, 1, -1 do
	print("Lift off in " .. i)
	task.wait(1)
end
challenge icon

챌린지

중급

로비 게시판에서 각 타워가 나타날 때까지 카운트다운하세요.

  1. workspace.Lobby.Board에 SurfaceGui를 넣고, 이름이 Status인 TextLabel boardLabel을 포함시키세요. 크기는 UDim2.fromScale(1, 1)로 설정하고 TextScaled를 켜세요.
  2. boardLabel.Text를 설정하는 setBoard(text)를 작성하세요.
  3. 타워를 만들기 전에 Settings.Intermission부터 1까지 i를 카운트다운하세요. setBoard("Next tower in " .. i)를 실행한 다음 task.wait(1)을 실행하세요.

‘플레이’를 누르세요. 게시판에서 5부터 카운트다운한 다음 타워가 나타납니다. 그런 다음 ‘확인’을 누르세요.

직접 해보기

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local CollectionService = game:GetService("CollectionService")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Settings = require(game.ReplicatedStorage.Settings)

local stages = ServerStorage.Stages
local tower = nil
local lava = nil

print("Each tower has " .. Settings.StageCount .. " stages")

-- 모든 플레이어의 리더보드에 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)

-- 레슨 12: 여기에 Board가 들어갑니다

-- Kill 태그가 붙은 것은 무엇이든 생명을 앗아갑니다
local function killOnTouch(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end

-- 사라지는 발판은 누군가 밟으면 잠시 후 희미해졌다가 다시 나타납니다
local function makeVanish(part)
	part.Touched:Connect(function(hit)
		if part:GetAttribute("Gone") or not hit.Parent:FindFirstChild("Humanoid") then
			return
		end
		part:SetAttribute("Gone", true)
		task.wait(Settings.VanishDelay)
		part.Transparency = 0.8
		part.CanCollide = false
		task.wait(Settings.VanishTime)
		part.Transparency = 0
		part.CanCollide = true
		part:SetAttribute("Gone", nil)
	end)
end

-- 레이저는 Slide 오프셋만큼 이동했다가 돌아오기를 계속 반복합니다
local function makeSlide(part)
	local info = TweenInfo.new(Settings.SlideTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true)
	local goal = { Position = part.Position + part:GetAttribute("Slide") }
	TweenService:Create(part, info, goal):Play()
end

-- 점프 패드는 밟은 사람을 공중으로 튕겨 올립니다
local function bounce(hit)
	local root = hit.Parent:FindFirstChild("HumanoidRootPart")
	if root then
		root.AssemblyLinearVelocity = Vector3.new(0, Settings.BouncePower, 0)
	end
end

-- 회전 장애물은 매 프레임 조금씩 회전합니다
RunService.Heartbeat:Connect(function(dt)
	for _, spinner in CollectionService:GetTagged("Spinner") do
		if spinner:IsDescendantOf(workspace) then
			spinner:PivotTo(spinner:GetPivot() * CFrame.Angles(0, math.rad(Settings.SpinSpeed) * dt, 0))
		end
	end
end)

-- 태그에 따라 스테이지의 모든 장애물을 활성화합니다
local function setupStage(stage)
	for _, part in stage:GetDescendants() do
		if part:HasTag("Kill") then
			part.Touched:Connect(killOnTouch)
		end
		if part:HasTag("Vanish") then
			makeVanish(part)
		end
		if part:HasTag("Conveyor") then
			part.AssemblyLinearVelocity = part.CFrame.LookVector * Settings.BeltSpeed
		end
		if part:HasTag("Slider") then
			makeSlide(part)
		end
		if part:HasTag("Bounce") then
			part.Touched:Connect(bounce)
		end
	end
end

-- 스테이지 하나를 무작위로 선택합니다
local function pickStage()
	local all = stages:GetChildren()
	return all[math.random(1, #all)]
end

-- 모델의 복사본을 타워 위에 쌓고, 복사본과 새로운 꼭대기 높이를 반환합니다
local function stack(template, bottom)
	local copy = template:Clone()
	local box, size = copy:GetBoundingBox()
	local lift = bottom - (box.Position.Y - size.Y / 2)
	copy:PivotTo(copy:GetPivot() + Vector3.new(0, lift, 0))
	copy.Parent = tower
	return copy, bottom + size.Y
end

-- 아래에서 위로 새로운 무작위 타워를 만듭니다
local function buildTower()
	tower = Instance.new("Model")
	tower.Name = "Tower"
	tower.Parent = workspace
	local top = 0
	for i = 1, Settings.StageCount do
		local stage, newTop = stack(pickStage(), top)
		top = newTop
		setupStage(stage)
	end
	stack(ServerStorage.Finish, top)
	return top
end

-- 용암이 지면에서 타워 꼭대기 바로 아래까지 올라갑니다
local function startLava(top)
	lava = Instance.new("Part")
	lava.Name = "Lava"
	lava.Anchored = true
	lava.CanCollide = false
	lava.Size = Vector3.new(30, 2, 30)
	lava.Position = Vector3.new(0, -2, 0)
	lava.Color = Color3.fromRGB(255, 90, 20)
	lava.Material = Enum.Material.Neon
	lava.Parent = workspace
	lava.Touched:Connect(killOnTouch)
	local info = TweenInfo.new(top / Settings.LavaSpeed, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, Settings.LavaDelay)
	TweenService:Create(lava, info, { Position = Vector3.new(0, top - 2, 0) }):Play()
end

startLava(buildTower())

Roblox 게임: 끝없는 타워의 모든 레슨

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