Menu
CoddyTech

플레이어 순간 이동

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

Spawn으로 이동하고, 라운드가 끝나면 로비로 돌아갑니다.

Players:GetPlayers()는 게임에 있는 모든 플레이어를 나열하며, 플레이어의 캐릭터는 Model인 player.Character입니다. Model:PivotTo(cframe)는 모델 전체를 한 번에 이동시키며, 각 파트는 서로에 대한 위치를 유지합니다. CFrame은 위치와 회전을 나타내며, Vector3를 더하면 위치가 이동합니다.

local function teleport(player, target)
	local character = player.Character
	if character then
		character:PivotTo(target.CFrame + Vector3.new(0, 4, 0))
	end
end
player.Character가 nil이므로 if가 필요합니다.

challenge icon

챌린지

중급

플레이어들을 섬으로 보냈다가 다시 돌아오게 하세요.

  1. teleport(player, target)를 작성하세요. player.Character가 있으면 PivotTo(target.CFrame + Vector3.new(0, 4, 0))을 실행하세요.
  2. 맵을 불러온 직후, 모든 플레이어를 map.Spawn으로 텔레포트하세요.
  3. 라운드 카운트다운이 끝나면 맵을 파괴하기 전에 모두를 lobbySpawn으로 텔레포트하세요.

‘플레이’를 누르세요. 라운드가 시작되면 섬에 도착하고, 라운드가 끝나면 로비로 돌아옵니다. 그런 다음 ‘확인’을 누르세요.

직접 해보기

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
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

-- Lesson 6: Teleport Players 코드를 여기에 작성합니다

-- 라운드 반복문
while true do
	for seconds = Settings.Intermission, 1, -1 do
		setStatus("Intermission: " .. seconds)
		task.wait(1)
	end

	local map = ServerStorage.Maps.Island:Clone()
	map.Name = "Map"
	map.Parent = workspace

	for seconds = Settings.RoundLength, 1, -1 do
		setStatus("Time left: " .. seconds)
		task.wait(1)
	end

	map:Destroy()
end

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

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