맵 불러오기
Coddy의 Roblox 게임: 재난 생존 코스 레슨. 18개 중 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를 복제하고, 복제본의 이름을Map으로 지정한 다음 workspace의 자식으로 설정하세요. - 라운드 카운트다운이 끝나면 맵을 제거하세요.
Play를 누르세요. 라운드가 시작되면 로비에서 멀리 앞쪽에 섬이 나타납니다. 그런 다음 Check를 누르세요.
직접 해보기
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
for seconds = Settings.RoundLength, 1, -1 do
setStatus("Time left: " .. seconds)
task.wait(1)
end
end
이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.