SpawnLocationクラス

クラス日本語解説あり

ひとことで言うと

プレイヤーが出現(スポーン)する場所になるパーツです。チェックポイントにも使えます。

公式の説明(英語):Class.SpawnLocation|SpawnLocations, or "spawns" determine where a Player respawns when they die. They can be configured to allow only certain players to use each spawn, using Class.Team|Teams. They also control how Class.ForceField|ForceFields are set up for newly-spawned players.

使用例

チェックポイントを作る
Script置く場所:SpawnLocationの中
local Players = game:GetService("Players")
local checkpoint = script.Parent :: SpawnLocation

checkpoint.Touched:Connect(function(hit)
	local character = hit.Parent
	if not character or not character:IsA("Model") then
		return
	end
	local player = Players:GetPlayerFromCharacter(character)
	if player then
		player.RespawnLocation = checkpoint
	end
end)

スクリプトは、Luauの型チェック(luau-lsp)で確認しています。

クラスの関係

受け継いでいるクラス:Object → Instance → PVInstance → BasePart → FormFactorPart → Part → SpawnLocation

プロパティ(5)

名前と書き方説明
AllowTeamChangeOnTouch
SpawnLocation.AllowTeamChangeOnTouch: boolean
Allows a Player to join the team by touching the SpawnLocation. When set to true, if a Player character comes into contact with the SpawnLocation, the player's Player.TeamColor will be set to SpawnLocation.TeamColor.
Duration
SpawnLocation.Duration: int
出現したあと、守られている(フォースフィールド)秒数。The length of time, in seconds, that a ForceField will be applied to a Player character spawning at this SpawnLocation. If Duration is zero, the ForceField is never created, and it will not trigger the Instance.DescendantAdded or Instance.ChildAdded events.
Enabled
SpawnLocation.Enabled: boolean
Sets whether or not the SpawnLocation is enabled. When disabled players cannot spawn at the SpawnLocation and the AllowTeamChangeOnTouch functionality is disabled.
Neutral
SpawnLocation.Neutral: boolean
trueにすると、どのチームのプレイヤーもここから出現します。Whether or not a SpawnLocation is affiliated with a specific team. This means that any Player, of any Team, can spawn on it if this property is set to true.
TeamColor
SpawnLocation.TeamColor: BrickColor
出現できるチームの色。Sets what team the SpawnLocation is affiliated to. If SpawnLocation.Neutral property is false, only Class.Player|Players with the same Player.TeamColor as the spawn's TeamColor will be able to spawn there.

受け継いでいるメンバー

Part から受け継いでいるもの(1)

Shape

BasePart から受け継いでいるもの(66)

Anchored・AssemblyAngularVelocity・AssemblyCenterOfMass・AssemblyLinearVelocity・AssemblyMass・AssemblyRootPart・AudioCanCollide・BackSurface・BottomSurface・BrickColor・CanCollide・CanQuery・CanTouch・CastShadow・CenterOfMass・CFrame・CollisionGroup・Color・CurrentPhysicalProperties・CustomPhysicalProperties・EnableFluidForces・ExtentsCFrame・ExtentsSize・FrontSurface・LeftSurface・Locked・Mass・Massless・Material・MaterialVariant・PivotOffset・Reflectance・ResizeableFaces・ResizeIncrement・RightSurface・RootPriority・Rotation・Size・TopSurface・Transparency・AngularAccelerationToTorque・ApplyAngularImpulse・ApplyImpulse・ApplyImpulseAtPosition・BindToCollisionSummaries・CanCollideWith・CanSetNetworkOwnership・GetClosestPointOnSurface・GetConnectedParts・GetJoints・GetMass・GetNetworkOwner・GetNetworkOwnershipAuto・GetNoCollisionConstraints・GetTouchingParts・GetVelocityAtPosition・IntersectAsync・IsGrounded・Resize・SetNetworkOwner・SetNetworkOwnershipAuto・SubtractAsync・TorqueToAngularAcceleration・UnionAsync・Touched・TouchEnded

PVInstance から受け継いでいるもの(4)

Origin・Pivot Offset・GetPivot・PivotTo

Instance から受け継いでいるもの(46)

Archivable・Capabilities・IsInSandbox・Name・Parent・PredictionMode・Sandboxed・AddTag・ClearAllChildren・Clone・Destroy・FindFirstAncestor・FindFirstAncestorOfClass・FindFirstAncestorWhichIsA・FindFirstChild・FindFirstChildOfClass・FindFirstChildWhichIsA・FindFirstDescendant・GetActor・GetAttribute・GetAttributeChangedSignal・GetAttributes・GetChildren・GetDebugId・GetDescendants・GetFullName・GetStyled・GetStyledPropertyChangedSignal・GetTags・HasTag・IsAncestorOf・IsDescendantOf・IsPropertyModified・QueryDescendants・RemoveTag・ResetPropertyToDefault・SetAttribute・WaitForChild・AncestryChanged・AttributeChanged・ChildAdded・ChildRemoved・DescendantAdded・DescendantRemoving・Destroying・StyledPropertiesChanged

Object から受け継いでいるもの(4)

ClassName・GetPropertyChangedSignal・IsA・Changed

SpawnLocationを使う記事

英語の説明とメンバーの一覧は、Roblox Creator Documentation(SpawnLocation)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。

執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。沖縄マイクラ部 クロスウェーブで、ロブロックス(Roblox)・マインクラフト(マイクラ)・Scratchなどのプログラミングを指導。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにロブロックス(Roblox)やマインクラフト(マイクラ)のプログラミングを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む