Enable Controls When Someone is Sitting On A Seat

Hey! I’ve been looking everywhere but I can’t really find out how its called or how to do it.
First of all, I am a beginner scripter with little to no knowledge.

I am trying to get my plane seat to enable controls for the plane once you sit down at the seat of the plane.
For example: If you sit on the plane seat, you can press “F” and then it will play a sound of an engine starting and enable particles.

I only want this to work when you sit down on the plane seat.

Thanks for helping :grin:

local seat = script.Parent
local uis = game:GetService("UserInputService")
local connection

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if seat.Occupant then
		connection = uis.InputBegan:Connect(function(key, processed)
			if processed then
				return
			end
			--perform actions here
		end)
	elseif not seat.Occupant then
		if connection then
			connection:Disconnect()
		end
	end
end)
1 Like

Thanks a lot, you safed my day! :relaxed: