# Model（ロブロックス クラス）

> いくつものパーツをひとまとめにする入れ物です。キャラクターや建物など、複数の部品でできたものはModelになっています。

- URL：https://roblox.minecraft-okinawa.com/reference/classes/Model/
- 公式：https://create.roblox.com/docs/reference/engine/classes/Model
- 受け継いでいるクラス：PVInstance

## 使用例：ふれたプレイヤーをテレポートさせる

（Script／置く場所：テレポート台のパーツの中（行き先にTeleportTargetという名前のパーツを置く））

```lua
local pad = script.Parent :: BasePart
local target = workspace:WaitForChild("TeleportTarget") :: BasePart

pad.Touched:Connect(function(hit)
	local character = hit.Parent
	if character and character:IsA("Model") and character:FindFirstChildWhichIsA("Humanoid") then
		character:PivotTo(target.CFrame + Vector3.new(0, 5, 0))
	end
end)
```

## プロパティ

- `Model.LevelOfDetail: ModelLevelOfDetail`：Sets the level of detail on the model for experiences with instance streaming enabled.
- `Model.ModelStreamingMode: ModelStreamingMode`：Controls the model streaming behavior on Class.Model|Models when instance streaming is enabled.
- `Model.PrimaryPart: BasePart`：モデルの基準になるパーツ。PivotToなどで動かすときの基準になります。
- `Model.Scale: float`：Editor-only property used to scale the model around its pivot. Setting this property will move the scale as though Class.Model:ScaleTo() was called on it.
- `Model.WorldPivot: CFrame`：Determines where the pivot of a Model which does **not** have a set Model.PrimaryPart is located.

## メソッド

- `Model:AddPersistentPlayer(playerInstance: Player): ()`：Sets this model to be persistent for the specified player. Class.Model.ModelStreamingMode|ModelStreamingMode must be set to Enum.ModelStreamingMode|PersistentPerPlayer for behavior to be changed as a result of addition.
- `Model:GetBoundingBox(): Tuple`：Returns a description of a volume that contains all parts of a Model.
- `Model:GetExtentsSize(): Vector3`：Returns the size of the smallest bounding box that contains all of the Class.BasePart|BaseParts in the Model, aligned with the Model.PrimaryPart if it is set.
- `Model:GetPersistentPlayers(): List<Player>`：Returns all the Player objects that this model object is persistent for. Behavior varies based on whether this method is called from a Script or a LocalScript.
- `Model:GetScale(): float`：Returns the canonical scale of the model, which defaults to 1 for newly created models and will change as it is scaled via Class.Model:ScaleTo().
- `Model:MoveTo(position: Vector3): ()`：Moves the Class.Model.PrimaryPart|PrimaryPart to the given position. If a primary part has not been specified, the root part of the model will be used.
- `Model:RemovePersistentPlayer(playerInstance: Player): ()`：Makes this model no longer persistent for the specified player. Class.Model.ModelStreamingMode|ModelStreamingMode must be set to Enum.ModelStreamingMode|PersistentPerPlayer for behavior to be changed as a result of removal.
- `Model:ScaleTo(newScaleFactor: float): ()`：モデル全体の大きさを、指定した倍率に変えます。
- `Model:TranslateBy(delta: Vector3): ()`：Shifts a Model by the given Vector3 offset, preserving the model's orientation. If another BasePart or Terrain already exists at the new position then the Model will overlap said object.

英語の説明とメンバー一覧：Roblox Creator Documentation（CC BY 4.0）。日本語の解説はこのサイト独自のものです。

執筆：鈴木孝昌（現役プロジェクトマネージャー／プログラミング講師）／運営：沖縄マイクラ部 プログラミングスクール「クロスウェーブ」（https://minecraft-okinawa.com/）