Anyone have a way where I can detect when a player sits in a seat, and then open a GUI. When they get up from the seat, it closes?
COMMUNITY QUESTION
Is there a way to open a GUI when a player sits in a seat?
1 answer
You could use a Changed event to detect when the occupant property of the seat changes to a new humanoid. When the property is nil, the seat is empty. When someone sits in the seat, the occupant property gets set to that player's humanoid.
####Example
local seat = LOCATION_OF_SEAT
seat.Changed:connect(function(property)
if property == "Occupant" then
local humanoid = seat.Occupant
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
if player then
-- code
end
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Yes.
Yes.[2]