如何检测玩家坐下

我在想是否有一种简单的方法可以检测特定椅子上的玩家坐下,而不是检测玩家是否触摸座位,因为这并不总是有效的。

点赞
用户2860267
用户2860267

Humanoid.Seated 信号。

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

        -- 监听玩家坐下事件
        character.Humanoid.Seated:Connect(function(active, seatPart)
            -- active (bool) : 当玩家坐下时为 true
            -- seatPart (Instance of Seat or VehicleSeat) : 玩家刚刚坐下或离开的座位
            print(string.format("%s 是否坐下?%s", player.Name, active and "是" or "否"))
            print("有关的座位 : ", seatPart)
        end)
    end)
end)
2021-06-24 02:57:44