Seats can be occupied by non-player characters, so these members would respect that. The events are for convenience – it is possible to achieve the same thing by listening to [tt]Seat.ChildAdded[/tt].
player = nil
seat.ChildAdded:connect(function(it)
if it.ClassName == "Weld" and it.Name == "SeatWeld" then
player = it.Part1.Parent
OnSit(it.Part1.Parent)
end
end)
seat.ChildRemoving:connect(function(it)
if it.ClassName == "Weld" and it.Name == "SeatWeld" then
OnStand(it.Part1.Parent)
player = nil
end
end)
We all know it’s programmatically possible to determine who’s sitting in a seat using the SeatWeld. However, it shouldn’t be necessary to learn about how ROBLOX creates SeatWelds in order to detect when the seat is occupied. This should be built-in, since it’s frequently asked about.