How to detect when player is in a VehicleSeat

I’m scripting a nitro system for a car and I want it to function when the player presses F and when they’re in a VehicleSeat. The issue is I don’t know how to check if the player is in a VehicleSeat or not

local Occupant = Seat.Occupant -- Humanoid or nil

if Occupant then --If there is a Humanoid Detected in the Seat
   print"A Player is in the Seat"
end

What if there’s multiple VehicleSeats in the game though? What you sent only works with one VehicleSeat defined

for _,i in pairs(Example:GetChildren()) do
   if i:IsA("Seat") then
      i:GetPropertyChangedSignal("Occupant"):Connect(function()
          if i.Occupant then
             print"Someone is in the Seat"
          end
      end)
   end
end

Same issue as before but with cars. “Example” would be the car and there could be multiple cars in the game

New cars could be spawned in and it’s just adding layers of complication. I’m mainly looking for a way to see if the player is in a VehicleSeat based off their character or humanoid.

Found a way. There is a property called SeatPart inside of the humanoid

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.