Workspaceクラス

クラスサービス(game:GetService("Workspace")で取り出す)Instance.newでは作れない日本語解説あり

ひとことで言うと

ゲームの世界そのものを表すサービスです。Workspaceの中に入れたパーツやモデルが、ゲームの画面に表示されます。スクリプトからは workspace と書いて使えます。

公式の説明(英語):Workspace houses 3D objects which are rendered to the 3D world. Objects not descending from it will not be rendered or physically interact with the world.

使用例

光線(レイキャスト)で地面を調べる
Script置く場所:ServerScriptService
local origin = Vector3.new(0, 50, 0)
local direction = Vector3.new(0, -100, 0)

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude

local result = workspace:Raycast(origin, direction, params)
if result then
	print("当たったもの:" .. result.Instance.Name, result.Position)
end

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

クラスの関係

受け継いでいるクラス:Object → Instance → PVInstance → Model → WorldRoot → Workspace

プロパティ(48)

名前と書き方説明
AirDensity
Workspace.AirDensity: float
The air density at ground level, used in the aerodynamic force model.
AirTurbulenceIntensity
Workspace.AirTurbulenceIntensity: float
Controls the strength of turbulence present in the wind velocity field, affecting the aerodynamic force model.
AllowThirdPartySales
Workspace.AllowThirdPartySales: boolean
Determines whether assets created by other users can be sold in the game.
AuthorityMode
Workspace.AuthorityMode: AuthorityMode
Sets the server authority mode.
AvatarUnificationMode
Workspace.AvatarUnificationMode: AvatarUnificationMode
Enables the R6 to R15 adapter, allowing R15 avatars to join R6 experiences.
ClientAnimatorThrottling
Workspace.ClientAnimatorThrottling: ClientAnimatorThrottlingMode
Specifies the animation throttling mode for the local client.
CurrentCamera
Workspace.CurrentCamera: Camera
今使われているカメラ。The Camera object being used by the local player.
DistributedGameTime
Workspace.DistributedGameTime: double
The amount of time, in seconds, that the game has been running.
EnableSLIMAvatars
Workspace.EnableSLIMAvatars: RolloutState
Controls whether SLIM rendering is used for avatars in the experience.
FallenPartsDestroyHeight
Workspace.FallenPartsDestroyHeight: float
Determines the height at which falling Class.BasePart|BaseParts and their ancestor Class.Model|Models are removed from Workspace.
FallHeightEnabled
Workspace.FallHeightEnabled: boolean
Controls whether parts that fall below Workspace.FallenPartsDestroyHeight are automatically destroyed.
FluidForces
Workspace.FluidForces: FluidForces
Determines whether the physics engine computes aerodynamic forces on Class.BasePart|BaseParts whose Class.BasePart.EnableFluidForces|EnableFluidForces property is true.
GlobalWind
Workspace.GlobalWind: Vector3
Specifies the global wind vector for animated terrain grass, dynamic clouds, and particles.
Gravity
Workspace.Gravity: float
重力の強さ。初期値は196.2です。小さくすると、ふわっと高くジャンプできます。Determines the acceleration due to gravity applied to falling Class.BasePart|BaseParts.
IKControlConstraintSupport
Workspace.IKControlConstraintSupport: IKControlConstraintSupport
Enables support for constraints for IKControls. If disabled, IKControls ignore physics constraints.
ImprovedPhysicsReplication
Workspace.ImprovedPhysicsReplication: RolloutState
Controls whether the experience uses the improved physics replication path between the server and clients.
InsertPoint
Workspace.InsertPoint: Vector3
The world position at which new objects are placed when inserted from the toolbox.
LayeredClothingCacheOptimizations
Workspace.LayeredClothingCacheOptimizations: RolloutState
Controls whether layered clothing cache optimizations are enabled.
LuauTypeCheckMode
Workspace.LuauTypeCheckMode: LuauTypeCheckMode
Sets the Luau type checking mode for scripts in the experience.
MeshPartHeadsAndAccessories
Workspace.MeshPartHeadsAndAccessories: MeshPartHeadsAndAccessories
Sets whether character Heads and Accessories should be downloaded as MeshParts.
MeshStreamingAndImprovedLods
Workspace.MeshStreamingAndImprovedLods: RolloutState
Controls whether the experience uses the new mesh streaming and improved LOD system.
ModelStreamingBehavior
Workspace.ModelStreamingBehavior: ModelStreamingBehavior
Controls how Class.Model|Models are replicated in experiences when instance streaming is enabled.
NextGenerationReplication
Workspace.NextGenerationReplication: RolloutState
When true, enables an alternate replication system that alters and improves how properties are replicated under the hood.
NextGenerationReplicationAlias
Workspace.NextGenerationReplicationAlias: RolloutState
PathfindingUseImprovedSearch
Workspace.PathfindingUseImprovedSearch: PathfindingUseImprovedSearch
Controls whether an improved search algorithm is used by PathfindingService.
PhysicsSteppingMethod
Workspace.PhysicsSteppingMethod: PhysicsSteppingMethod
Sets how the solver will advance the physics simulation forward in time.
PlayerCharacterDestroyBehavior
Workspace.PlayerCharacterDestroyBehavior: PlayerCharacterDestroyBehavior
Controls whether the engine automatically calls Destroy() on a player's character when it is replaced and on the Player object when the player leaves.
PlayerScriptsUseInputActionSystemAlias
Workspace.PlayerScriptsUseInputActionSystemAlias: RolloutState
PredictiveStreamingMode
Workspace.PredictiveStreamingMode: PredictiveStreamingMode
Controls whether the engine can make predictive streaming decisions.
NextGenerationPhysicsSolver
Workspace.NextGenerationPhysicsSolver: RolloutState
Controls whether the experimental next generation physics solver is enabled.
RejectCharacterDeletions
Workspace.RejectCharacterDeletions: RejectCharacterDeletions
Controls whether the server rejects attempts by clients to delete player characters from the workspace.
RenderingCacheOptimizations
Workspace.RenderingCacheOptimizations: RenderingCacheOptimizationMode
Controls whether rendering cache optimizations are enabled.
ReplicateInstanceDestroySetting
Workspace.ReplicateInstanceDestroySetting: ReplicateInstanceDestroySetting
Controls how Instance:Destroy() calls are replicated from the server to clients.
Retargeting
Workspace.Retargeting: AnimatorRetargetingMode
Controls whether animation retargeting is enabled for character animations.
SandboxedInstanceMode
Workspace.SandboxedInstanceMode: SandboxedInstanceMode
Controls whether sandboxed instance mode (script capabilities) is enabled.
SignalBehavior
Workspace.SignalBehavior: SignalBehavior
Configures when the engine resumes event handlers.
SignalBehaviorAlias
Workspace.SignalBehaviorAlias: SignalBehavior
StreamingEnabled
Workspace.StreamingEnabled: boolean
Whether content streaming is enabled for the place.
StreamingEnabledAlias
Workspace.StreamingEnabledAlias: boolean
StreamingIntegrityMode
Workspace.StreamingIntegrityMode: StreamingIntegrityMode
Determines whether streaming integrity mode is active.
StreamingMinRadius
Workspace.StreamingMinRadius: int
Minimum distance that content will be streamed to players with high priority.
StreamingTargetRadius
Workspace.StreamingTargetRadius: int
Maximum distance that content will be streamed to players.
StreamOutBehavior
Workspace.StreamOutBehavior: StreamOutBehavior
Configures how the engine decides when to stream content away from players.
Terrain
Workspace.Terrain: Terrain
A reference to the Terrain object parented to the Workspace.
TouchesUseCollisionGroups
Workspace.TouchesUseCollisionGroups: boolean
Determines whether Class.BasePart|parts in different groups set to not collide will ignore collisions and touch events.
UseFixedSimulation
Workspace.UseFixedSimulation: RolloutState
When true, enables Class.RunService:BindToSimulation() which calls a function at a fixed frequency, updates physics stepping logic, and makes the Global.RobloxGlobals.time() function return the fixed stepped frame time.
UseFixedSimulationAlias
Workspace.UseFixedSimulationAlias: RolloutState
UseNewLuauTypeSolver
Workspace.UseNewLuauTypeSolver: RolloutState
Controls whether the new Luau type solver is used for type inference.

メソッド(9)

名前と書き方説明
ApplyRecommendedStreamingSettings
Workspace:ApplyRecommendedStreamingSettings(): boolean
Applies Roblox's recommended instance streaming settings to the Workspace.
GetNumAwakeParts
Workspace:GetNumAwakeParts(): int
Returns the number of Class.BasePart|BaseParts that are deemed physically active, due to being recently under the influence of physics.
GetPhysicsThrottling
Workspace:GetPhysicsThrottling(): int
Returns an integer, between 0 and 100, representing the percentage of real time that physics simulation is currently being throttled to.
GetRealPhysicsFPS
Workspace:GetRealPhysicsFPS(): double
Returns the number of frames per second that physics is currently being simulated at.
GetServerTimeNow
Workspace:GetServerTimeNow(): double
Returns the server's Unix time in seconds.
JoinToOutsiders
Workspace:JoinToOutsiders(objects: Instances, jointType: JointCreationMode): ()
Creates joints between the specified Class.BasePart|Parts and any touching parts depending on the parts' surfaces and the specified joint creation mode.
PGSIsEnabled
Workspace:PGSIsEnabled(): boolean
Returns true if the game has the PGS Physics solver enabled.
UnjoinFromOutsiders
Workspace:UnjoinFromOutsiders(objects: Instances): ()
Breaks all joints between the specified Class.BasePart|BaseParts and other Class.BasePart|BaseParts.
ZoomToExtents
Workspace:ZoomToExtents(): ()
Positions and zooms the Workspace.CurrentCamera to show the extent of Class.BasePart|BaseParts currently in the Workspace.

イベント(1)

名前と書き方説明
PersistentLoaded
Workspace.PersistentLoaded(player: Player)
Fires when persistent models have been sent to the specified player.

受け継いでいるメンバー

WorldRoot から受け継いでいるもの(19)

ArePartsTouchingOthers・Blockcast・BulkMoveTo・CollisionGroupsAreCollidable・CollisionGroupSetCollidable・GetMaxCollisionGroups・GetPartBoundsInBox・GetPartBoundsInRadius・GetPartsInPart・GetRegisteredCollisionGroups・IKMoveTo・IsCollisionGroupRegistered・Raycast・RegisterCollisionGroup・RenameCollisionGroup・Shapecast・Spherecast・StepPhysics・UnregisterCollisionGroup

Model から受け継いでいるもの(14)

LevelOfDetail・ModelStreamingMode・PrimaryPart・Scale・WorldPivot・AddPersistentPlayer・GetBoundingBox・GetExtentsSize・GetPersistentPlayers・GetScale・MoveTo・RemovePersistentPlayer・ScaleTo・TranslateBy

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

Workspaceを使う記事

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

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