Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to detect if seat is occupied or not?

How do I detect if a player sat on a seat and when the player leaves?

1 answer

✓ Accepted answer
-- Server Script

local Players = game:GetService("Players") 

Players.PlayerAdded:Connect(function(Player) -- When a player joins
   Player.CharacterAdded:Connect(function(Character) -- When the player spawns
   local Humanoid = Character.Humanoid -- Retrieving the humanoid to get the SeatPart prop
	
    Humanoid:GetPropertyChangedSignal('SeatPart'):Connect(function() -- When the SeatPart prop changes
	 if not Humanoid.SeatPart then 
		 print('Player left seat') 
		else 
		 print('Player sat')
	   end
	 end)
   end)
end)

Hope this helps. Anything else you need make sure to ask me.

1 comment

1

Great answer. Much more efficient than Seat.Occupant.

This discussion is preserved as it was. New answers, comments, and votes are closed.