Seat

非推奨を表示

A type of BasePart that a player character can 'sit' in. When a character touches an enabled Seat object, it will be attached to the part by a Weld and the default character scripts will play a sitting animation.

How do Seats work?

When a model containing a Humanoid and a BasePart called 'HumanoidRootPart' (generally a player character) touches a seat, a Weld is created between the seat and the part. The C0 and C1 properties are configured so that the character is welded 2 studs above the seat. This weld is named 'SeatWeld' and parented to the seat.

When sitting the Seat.Occupant property is set to the Humanoid that is 'sitting' in the seat. Furthermore the Humanoid.SeatPart property of the humanoid is set to the seat.

A character can also be forced to sit in a seat using the Seat:Sit() function.

There are two ways for a character to get out of a seat. When a player jumps, they are removed from the seat. However this can also be done manually by destroying the seat weld, for example:


seat:FindFirstChild("SeatWeld"):Destroy()

Note seats have a cooldown (currently 3 seconds) that is on a per-character per-seat basis. This means once a character has gotten out of a seat they cannot sit back on the same seat for 3 seconds. This cooldown behavior may change and should not be relied upon by developers.

What can Seats be used for?

Seats have a diverse range of uses, ranging from the obvious to the more unconventional.

  • Creating chairs or benches without the need for any programming
  • Allowing characters to 'sit' in moving objects such as vehicles without getting flung around
  • Creating interfaces that are controlled by the character in the seat using the Seat.Occupant property

コードサンプル

Detecting Seat Occupant

local Players = game:GetService("Players")
local seat = Instance.new("Seat")
seat.Anchored = true
seat.Position = Vector3.new(0, 1, 0)
seat.Parent = workspace
local currentPlayer = nil
local function onOccupantChanged()
local humanoid = seat.Occupant
if humanoid then
local character = humanoid.Parent
local player = Players:GetPlayerFromCharacter(character)
if player then
print(player.Name .. " has sat down")
currentPlayer = player
return
end
end
if currentPlayer then
print(currentPlayer.Name .. " has got up")
currentPlayer = nil
end
end
seat:GetPropertyChangedSignal("Occupant"):Connect(onOccupantChanged)

概要

プロパティ

  • 並列読み取り

    Whether or not the seat is usable. If set to true, the seat will act as a normal part.

  • 読み取り専用
    複製されていません
    並列読み取り

    The humanoid that is sitting in the seat.

Part から継承した プロパティ
  • 複製されていません
    並列読み取り

    Sets the overall shape of the object.

BasePart から継承した プロパティ
  • 並列読み取り

    Determines whether a part is immovable by physics.

  • 複製されていません
    並列読み取り

    The angular velocity of the part's assembly.

  • 読み取り専用
    複製されていません
    並列読み取り

    The center of mass of the part's assembly in world space.

  • 複製されていません
    並列読み取り

    The linear velocity of the part's assembly.

  • 読み取り専用
    複製されていません
    並列読み取り

    The total mass of the part's assembly.

  • 読み取り専用
    複製されていません
    並列読み取り

    A reference to the root part of the assembly.

  • 並列読み取り

    Determines the type of surface for the Back face of a part (+Z direction).

  • Determines the type of surface for the Bottom face of a part (-Y direction).

  • 複製されていません
    並列読み取り

    Determines the color of a part.

  • 並列読み取り

    Determines the position and orientation of the BasePart in the world.

  • 並列読み取り

    Determines whether a part may collide with other parts.

  • 並列読み取り

    Determines whether the part is considered during spatial query operations.

  • 並列読み取り

    Determines if Touched and TouchEnded events fire on the part.

  • 並列読み取り

    Determines whether or not a part casts a shadow.

  • 読み取り専用
    複製されていません
    並列読み取り

    Describes the world position in which a part's center of mass is located.

  • 複製されていません
    並列読み取り

    Describes the name of a part's collision group.

  • 複製されていません
    並列読み取り

    Determines the color of a part.

  • 読み取り専用
    複製されていません
    並列読み取り

    Indicates the current physical properties of the part.

  • Determines several physical properties of a part.

  • 並列読み取り

    Used to enable or disable aerodynamic forces on parts and assemblies.

  • 読み取り専用
    複製されていません
    並列読み取り

    The CFrame of the physical extents of the BasePart.

  • 読み取り専用
    複製されていません
    並列読み取り

    The actual physical size of the BasePart as regarded by the physics engine.

  • 並列読み取り

    Determines the type of surface for the Front face of a part (-Z direction).

  • 並列読み取り

    Determines the type of surface for the Left face of a part (-X direction).

  • 非表示
    複製されていません
    並列読み取り

    Determines a multiplier for BasePart.Transparency that is only visible to the local client.

  • 並列読み取り

    Determines whether a part is selectable in Studio.

  • 読み取り専用
    複製されていません
    並列読み取り

    Describes the mass of the part, the product of its density and volume.

  • 並列読み取り

    Determines whether the part contributes to the total mass or inertia of its rigid body.

  • 並列読み取り

    Determines the texture and default physical properties of a part.

  • 複製されていません
    並列読み取り

    The name of MaterialVariant.

  • 非表示
    複製されていません
    並列読み取り

    Describes the rotation of the part in the world.

  • 並列読み取り

    Specifies the offset of the part's pivot from its CFrame.

  • 非表示
    複製されていません
    並列読み取り

    Describes the position of the part in the world.

  • 非表示
    読み取り専用
    複製されていません
    並列読み取り

    Time since last recorded physics update.

  • 並列読み取り

    Determines how much a part reflects the skybox.

  • 読み取り専用
    複製されていません
    並列読み取り

    Describes the smallest change in size allowable by the Resize method.

  • 読み取り専用
    複製されていません
    並列読み取り

    Describes the faces on which a part may be resized.

  • 並列読み取り

    Determines the type of surface for the Right face of a part (+X direction).

  • 並列読み取り

    The main rule in determining the root part of an assembly.

  • 複製されていません
    並列読み取り

    The rotation of the part in degrees for the three axes.

  • 複製されていません
    並列読み取り

    Determines the dimensions of a part (length, width, height).

  • 並列読み取り

    Determines the type of surface for the Top face of a part (+Y direction).

  • 並列読み取り

    Determines how much a part can be seen through (the inverse of part opacity).

PVInstance から継承した プロパティ
  • 複製されていません
    スクリプト作成できません
    並列読み取り
  • 複製されていません
    スクリプト作成できません
    並列読み取り

方法

  • Sit(humanoid : Instance):void

    Forces the character with the specified Humanoid to sit in the Seat.

BasePart から継承した 方法PVInstance から継承した 方法

イベント

BasePart から継承した イベント

プロパティ

Disabled

並列読み取り

Whether or not the seat is usable. If set to true, the seat will act as a normal part.

Occupant

読み取り専用
複製されていません
並列読み取り

The humanoid that is sitting in the seat

方法

Sit

void

Forces the character with the specified Humanoid to sit in the Seat.

パラメータ

humanoid: Instance

戻り値

void

イベント