Hello, is there a way to put a script inside a seat to know when someone sits in it? I do not need to know who sits in the seat, but just I would like it to call a function when the seat was sat in.
Edited with better code sample: Make sure this is a localscript inside startercharacterscripts
01 | local character = script.Parent |
02 | local humanoid = character:WaitForChild( "Humanoid" ) |
03 |
04 | local mostRecentSeat = nil --the most recent seat that the player sat in |
05 |
06 | humanoid.Seated:Connect( function (isSeated, seat) |
07 | if isSeated then |
08 | if seat then |
09 | print ( "The player is now sitting in the seat named " ..seat.Name.. "!" ) |
10 | mostRecentSeat = seat |
11 | end |
12 | else |
13 | print ( "The player is no longer sitting in " ..mostRecentSeat) |
14 | end |
15 | end ) |