Menu
CoddyTech

방 번호

Coddy의 Roblox 게임: 어둠 속 탈출 코스 레슨. 25개 중 6번째.

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

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

player.RespawnLocation = room.Checkpoint

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

challenge icon

챌린지

중급

방에 번호를 매기고 체크포인트로 만드세요.

  1. 각 플레이어에게 leaderstats와 IntValue Room을 지정하세요.
  2. addRoom에서 Number 속성을 count로 설정하고 room.Sign.SurfaceGui.Number.Text를 "Room " .. count로 설정하세요.
  3. Lobby와 새로 만들어지는 각 방에서 호출되는 setupEntry(room)를 작성하세요. room.Entry에 닿으면 플레이어의 Room을 해당 방의 Number로 설정하고, RespawnLocation을 room.Checkpoint로 설정합니다.

‘플레이’를 누르고 1번 방으로 걸어 들어가세요. 방 표지판과 플레이어의 Room에 1이 표시됩니다. 그런 다음 ‘확인’을 누르세요.

직접 해보기

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)

-- Lesson 6: 방 번호는 여기에 작성

-- 가장 최근에 생성된 방의 출구에 새 방 생성
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)

Roblox 게임: 어둠 속 탈출의 모든 레슨

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