How do I detect if a player sat on a seat and when the player leaves?
01 | -- Server Script |
02 |
03 | local Players = game:GetService( "Players" ) |
04 |
05 | Players.PlayerAdded:Connect( function (Player) -- When a player joins |
06 | Player.CharacterAdded:Connect( function (Character) -- When the player spawns |
07 | local Humanoid = Character.Humanoid -- Retrieving the humanoid to get the SeatPart prop |
08 |
09 | Humanoid:GetPropertyChangedSignal( 'SeatPart' ):Connect( function () -- When the SeatPart prop changes |
10 | if not Humanoid.SeatPart then |
11 | print ( 'Player left seat' ) |
12 | else |
13 | print ( 'Player sat' ) |
14 | end |
15 | end ) |
16 | end ) |
17 | end ) |
Hope this helps. Anything else you need make sure to ask me.