Menu
CoddyTech

좀비 생성하기

Coddy의 Roblox 게임: 타워 디펜스 코스 레슨. 22개 중 2번째.

적들은 workspace.Path.Waypoints에 있는 보이지 않는 파트로 표시된 경로를 따라 이동하며, 파트의 이름은 1부터 6까지입니다. GetChildren은 순서를 보장하지 않으므로, 먼저 이름에 있는 숫자를 기준으로 정렬하세요:

local points = workspace.Path.Waypoints:GetChildren()
table.sort(points, function(a, b)
	return tonumber(a.Name) < tonumber(b.Name)
end)

각 적은 ServerStorage.Enemies에 있는 모델입니다. 모델을 복제하고, PivotTo로 모델 전체를 이동한 다음, 화면에 나타나도록 workspace에 부모로 지정하세요:

local runner = ServerStorage.Enemies.Runner:Clone()
runner:PivotTo(points[3].CFrame + Vector3.new(0, 4, 0))
runner.Parent = workspace.Enemies
challenge icon

챌린지

쉬움

경로 시작 지점에 Zombie를 떨어뜨리세요.

  1. 위쪽 근처에 local ServerStorage = game:GetService("ServerStorage")와 local enemies = workspace.Enemies를 작성하세요.
  2. workspace.Path.Waypoints:GetChildren()를 tonumber(a.Name)를 기준으로 정렬해 waypoints에 저장하세요.
  3. spawnEnemy(kind)를 작성하세요. ServerStorage.Enemies[kind]를 복제하고, PivotTo를 사용해 waypoints[1]에서 5 스터드 위로 이동한 다음, 부모를 enemies로 설정하고 반환하세요. spawnEnemy("Zombie")를 호출하세요.

‘플레이’를 누르면 경로 시작 지점에 Zombie가 떨어집니다. 그런 다음 ‘확인’을 누르세요.

직접 해보기

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

print("The base can take " .. Settings.BaseHealth .. " hits")

-- 모든 플레이어의 leaderboard에 Money가 표시됩니다
Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local money = Instance.new("IntValue")
	money.Name = "Money"
	money.Value = Settings.StartMoney
	money.Parent = leaderstats
end)

-- Lesson 2: Spawn a Zombie는 여기에 들어갑니다

Roblox 게임: 타워 디펜스의 모든 레슨

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