맵 불러오기
Coddy의 Roblox 게임: 재난 생존 코스 레슨. 20개 중 5번째.
라운드는 맵에서 진행됩니다. 맵은 ServerStorage에 보관됩니다. 이 서비스의 콘텐츠는 월드에 있지 않아 아무도 보거나 만질 수 없습니다. Explorer 개요에서 ServerStorage.Maps를 열면 Island를 찾을 수 있습니다.
라운드가 시작되면 Clone을 사용해 맵의 복사본을 workspace에 넣고, 라운드가 끝난 뒤 Destroy를 사용해 제거합니다. 원본은 ServerStorage에 그대로 남아 다음 라운드를 기다립니다:
local map = ServerStorage.Maps.Island:Clone()
map.Name = "Map"
map.Parent = workspace
-- ... 라운드 진행 ...
map:Destroy()복사본은 원본의 위치를 그대로 유지하므로, 섬은 로비에서 멀리 떨어진, 만들어진 위치에 나타납니다. 원본을 복제하는 대신 옮기면 한 번만 작동합니다. 첫 번째 Destroy 이후에는 두 번째 라운드에 사용할 Island가 남아 있지 않기 때문입니다.
챌린지
중급매 라운드마다 Island를 불러오세요.
- 맨 위에서
game:GetService로ServerStorage를 가져오세요. - 로비 카운트다운이 끝난 후,
ServerStorage.Maps.Island를local map으로 복제하고 이름을Map으로 지정한 다음 workspace에 부모로 설정하세요. - 라운드 카운트다운이 끝나면
map:Destroy()를 호출하세요.
‘플레이’를 누르세요. 라운드가 시작되면 로비에서 멀리 앞쪽에 섬이 나타나고 라운드가 끝나면 사라집니다. 그런 다음 ‘확인’을 누르세요.
직접 해보기
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
local function setStatus(text)
status.Text = text
end
-- 라운드 반복문
while true do
for seconds = Settings.Intermission, 1, -1 do
setStatus("Intermission: " .. seconds)
task.wait(1)
end
-- Lesson 5: Load a Map이 여기에 들어갑니다
for seconds = Settings.RoundLength, 1, -1 do
setStatus("Time left: " .. seconds)
task.wait(1)
end
end
Roblox 게임: 재난 생존의 모든 레슨
직접 연습해 보세요: Roblox 플레이그라운드