killerderp7
killerderp7

Reputation: 118

How to detect when a player sits

I was wondering if there is an easy way to detect when a player sits in a specific chair, other than detecting if the player touches the seat, which doesn't always work.

Upvotes: 0

Views: 1082

Answers (1)

Kylaaa
Kylaaa

Reputation: 7188

There is the Humanoid.Seated signal.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)

        -- listen for when the player sits down
        character.Humanoid.Seated:Connect(function(active, seatPart)
            -- active (bool) : true when a player is sitting
            -- seatPart (Instance of Seat or VehicleSeat) : the seat that the player has just sat in or left
            print(string.format("Is %s sitting? %s", player.Name, active and "yes" or "no")
            print("the seat in question : ", seatPart)
        end)
    end)
end)

Upvotes: 1

Related Questions