Menu
CoddyTech

플레이어 순간이동

Coddy의 Roblox 게임: 재난 생존 코스 레슨. 18개 중 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. 맨 위쪽에 로비의 스폰 지점을 유지하세요: local lobbySpawn = workspace.LobbySpawn.
  2. 강의에서처럼 teleport(player, target)을 작성하세요.
  3. 맵을 불러온 직후, 모든 플레이어를 map.Spawn으로 텔레포트하세요.
  4. 라운드 카운트다운이 끝나면 맵이 파괴되기 전에 모든 플레이어를 lobbySpawn으로 텔레포트하세요.

Play를 눌러 따라가 본 다음 Check를 누르세요.

직접 해보기

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

-- 라운드 반복문
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
quiz icon실력 점검

이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.

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