경험 내에서 친구를 찾는 것은 어려울 수 있습니다. SpawnWithFriends 개발자 모듈은 스폰하는 플레이어를 경험에 있는 친구 중 한 명 근처로 자동으로 이동시킵니다. 이 모듈은 자동으로 이동하는 대신 명령으로 플레이어를 텔레포트하도록 구성할 수도 있습니다.
모듈 사용법
설치
경험에서 SpawnWithFriends 모듈을 사용하려면:
Studio의 창 메뉴 또는 홈 탭 툴바에서 툴박스를 열고 크리에이터 스토어 탭을 선택합니다.

모델 정렬이 선택되었는지 확인한 후, 카테고리의 모두 보기 버튼을 클릭합니다.

패키지 타일을 찾아 클릭합니다.
친구와 함께 스폰 모듈을 찾아 클릭하거나 3D 뷰로 드래그 앤 드롭합니다.

탐색기 창에서 전체 SpawnWithFriends 모델을 ReplicatedStorage로 이동합니다. 경험을 실행하면 모듈이 실행되기 시작합니다.
제한된 스폰 구역
이 모듈은 VIP 룸, 출입 제한 공간 등과 같은 제한된 구역에 플레이어가 스폰되는 결과를 초래할 수 있습니다. 플레이어가 이러한 구역으로 텔레포트되는 것을 방지하려면:
제한된 구역에 보이지 않는 Anchored 블록으로 채웁니다. 모든 블록에 대해 CanCollide, CanTouch, 및 CanQuery가 비활성화되어 있는지 확인합니다.

플레이어가 내부에서 스폰되는 것을 방지하기 위해 전체 감옥 방을 채우는 블록 각 블록의 속성의 태그 섹션을 사용하여 RestrictedSpawnArea 태그를 적용하여 CollectionService가 이를 감지하도록 합니다.
ServerScriptService 내의 Script에 다음 코드를 붙여넣습니다.
스크립트local ReplicatedStorage = game:GetService("ReplicatedStorage")local CollectionService = game:GetService("CollectionService")local SpawnWithFriends = require(ReplicatedStorage.SpawnWithFriends)local function validator(playerToTeleport, destinationPlayer, teleportationPoint)-- 모든 태그가 있는 부분을 반복합니다.for _, area in CollectionService:GetTagged("RestrictedSpawnArea") dolocal relativePosition = area.CFrame:PointToObjectSpace(teleportationPoint.Position)local size = area.Sizelocal inXBounds = relativePosition.X < size.X / 2 and relativePosition.X > -size.X / 2local inZBounds = relativePosition.Z < size.Z / 2 and relativePosition.Z > -size.Z / 2if inXBounds and inZBounds thenreturn false -- 스폰 목적지가 제한된 구역 내에 있습니다; 텔레포트 중단endendreturn true -- 스폰 목적지가 제한된 구역과 겹치지 않음; 텔레포트 진행endSpawnWithFriends.setTeleportationValidator(validator)
API 참조
함수
configure
configure(config: table)
config 테이블의 다음 키/값을 통해 기본 구성 옵션을 재정의합니다. 이 함수는 Script에서만 호출할 수 있습니다.
| 키 | 설명 | 기본값 |
|---|---|---|
| teleportToFriendOnRespawn | 이것이 false로 설정되면, 친구에게 텔레포트는 teleportToRandomFriend를 통해 수동으로만 발생합니다. | true |
| teleportDistance | 플레이어가 서로에서 얼마나 떨어져 스폰되어야 하는지, 스터드 단위로 측정됩니다. | 5 |
| maxCharacterVelocity | 이 값을 초과하여 이동하는 캐릭터는 텔레포트 후보로 선택되지 않으며, 예를 들어 이동하는 차량에 있는 경우입니다. | 48 |
| bypassFriendshipCheck | true로 설정되면 모든 플레이어가 텔레포트 후보가 됩니다; 친구만이 아닙니다. | false |
| showLogs | 로그 메시지를 출력에 표시할지 여부입니다. | false |
스크립트local ReplicatedStorage = game:GetService("ReplicatedStorage")local SpawnWithFriends = require(ReplicatedStorage.SpawnWithFriends)SpawnWithFriends.configure({teleportToFriendOnRespawn = true,teleportDistance = 5,maxCharacterVelocity = 48,bypassFriendshipCheck = false,showLogs = false})
teleportToRandomFriend
teleportToRandomFriend(playerToTeleport: Player): boolean
경험에서 플레이어가 친구 중 한 명에게 텔레포트하도록 수동으로 트리거합니다. 텔레포트 성공 여부를 나타내는 불리언 값을 반환합니다; 텔레포트에 실패하는 이유는 서버의 친구가 없거나 방해받지 않는 텔레포트 지점을 찾을 수 없기 때문일 수 있습니다. 이 함수는 Script에서만 호출할 수 있습니다.
setTeleportationValidator
setTeleportationValidator(validator: function)
검증기 콜백 함수를 후킹하여 사용자 정의 텔레포트 전 검사를 수행할 수 있습니다. 콜백은 세 개의 매개변수를 받습니다:
| 매개변수 | 설명 |
|---|---|
| playerToTeleport | 텔레포트되는 Player에 대한 참조입니다. |
| destinationPlayer | playerToTeleport가 텔레포트되는 대상 Player에 대한 참조입니다. |
| teleportationPoint | playerToTeleport가 텔레포트하는 CFrame입니다. |
이 함수와 그 콜백은 Script에서만 사용할 수 있으며, 콜백은 텔레포트를 진행해야 할지를 나타내는 불리언 값을 반환합니다. 예를 들어, 아래 검증기 함수의 return 로직은 스폰하는 플레이어와 목적지 플레이어가 같은 팀에 있어야만 텔레포트가 진행되도록 보장합니다.
스크립트
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnWithFriends = require(ReplicatedStorage.SpawnWithFriends)
-- 플레이어가 같은 팀에 있을 때만 텔레포트
local function validator(playerToTeleport, destinationPlayer, teleportationPoint)
return playerToTeleport.Team == destinationPlayer.Team
end
SpawnWithFriends.setTeleportationValidator(validator)