Menu
CoddyTech

방 번호

Coddy의 Roblox 게임: 어둠에서 탈출하기 코스 레슨. 20개 중 6번째.

플레이어는 자신이 얼마나 깊이 있는지 알아야 합니다. 모든 방은 번호를 가집니다. 속성으로는 Number이고, 문 위의 표지판에는 (Sign.SurfaceGui.Number) 표시됩니다.

각 방에는 입구 안쪽 한 걸음 거리에 보이지 않는 Entry 파트가 있습니다. 플레이어의 몸이 이 파트에 닿으면 해당 방이 리더보드의 Room이 되고 체크포인트가 됩니다. 플레이어의 RespawnLocation은 플레이어가 돌아올 SpawnLocation이며, 각 방에는 하나씩 Checkpoint가 있습니다.

player.RespawnLocation = room.Checkpoint

Players:GetPlayerFromCharacter(hit.Parent)는 누구의 몸이 파트에 닿았는지 알려주거나 nil을 반환합니다.

challenge icon

챌린지

중급
  1. 모든 플레이어에게 리더보드에 Room을 표시합니다(leaderstats Folder와 IntValue 사용).
  2. addRoom에서 방의 Number 속성을 count로 설정하고 표지판에는 "Room " .. count를 표시합니다(첫 번째는 Room 1).
  3. setupEntry(room)를 작성합니다. 플레이어가 방의 Entry에 닿으면 플레이어의 Room을 방 번호로, RespawnLocation을 방의 Checkpoint로 설정합니다. Lobby와 새로 생성되는 모든 방에 이 함수를 호출합니다.

Play를 누른 다음 Check를 누릅니다.

직접 해보기

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

local rooms = workspace.Rooms
local lastRoom = rooms.Lobby -- 가장 최근에 생성된 방
local count = 0 -- 지금까지 생성된 방의 수

-- 밤이 찾아온다: 태양은 없고, 사방에 희미한 빛과 안개가 깔린다
Lighting.ClockTime = Settings.ClockTime
Lighting.Ambient = Settings.Ambient
Lighting.OutdoorAmbient = Settings.Ambient
Lighting.FogColor = Color3.new(0, 0, 0)
Lighting.FogEnd = Settings.FogEnd
print("Lights out")

-- 경첩을 축으로 문을 돌려 연다
local function openDoor(door)
	door:SetAttribute("Open", true)
	door.Panel.Prompt.Enabled = false
	local hinge, panel = door.Hinge, door.Panel
	local goal = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0) * hinge.CFrame:ToObjectSpace(panel.CFrame)
	TweenService:Create(panel, TweenInfo.new(0.6), { CFrame = goal }):Play()
end

local addRoom -- 아래에 작성됨: 문은 방을 추가하고, 방에는 문이 있다

-- 플레이어가 문을 열 때 문이 하는 일
local function setupDoor(door)
	door.Panel.Prompt.Triggered:Connect(function(player)
		if door:GetAttribute("Open") then
			return
		end
		if door.Parent == lastRoom then
			addRoom()
		end
		openDoor(door)
	end)
end
setupDoor(workspace.Rooms.Lobby.Door)

-- 가장 최근 방의 출구에 새 방 생성
function addRoom()
	count += 1
	local name = Settings.Order[(count - 1) % #Settings.Order + 1]
	if count >= Settings.RoomsToEscape then
		name = "Exit"
	end
	local room = ServerStorage.Rooms[name]:Clone()
	room:PivotTo(lastRoom.Exit.CFrame)
	room.Parent = rooms
	lastRoom = room
	setupDoor(room.Door)
	return room
end

-- 모든 플레이어: 생명마다 손전등 하나씩
Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		local flashlight = ServerStorage.Flashlight:Clone()
		flashlight.Parent = player.Backpack
		local beam = flashlight.Handle.Beam
		flashlight.Activated:Connect(function()
			beam.Enabled = not beam.Enabled
		end)
	end)
end)
quiz icon실력 점검

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

Roblox 게임: 어둠에서 탈출하기의 모든 레슨