【问题标题】:How to detect when a player sits如何检测玩家何时坐下
【发布时间】:2021-09-07 11:02:00
【问题描述】:

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

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    Humanoid.Seated 信号。

    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)
    

    【讨论】:

    • 谢谢,很有帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-26
    • 1970-01-01
    • 1970-01-01
    • 2020-09-11
    • 2014-02-01
    • 1970-01-01
    • 2021-04-11
    相关资源
    最近更新 更多