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

Is there a way to open a GUI when a player sits in a seat?

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?

2 comments

0

Yes.

0

Yes.[2]

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.