How to detect when an npc sits on a seat?

Hi im trying to make something to detect when an npc sits on a seat? Can anyone help out?

4 Likes

Doesn’t the humanoid have a “Sit” bool in the properties? Can you use that? Or check if the seat has someone in it?

Do you mind showing an example?

Sorry, I do not have access to my computer right now, but when i get the chance i will try to provide proof.

Ok thank you so much! I will test out the seat function

Yes, under the Control properties of the seat, there is a property called “Occupant”. I believe you can just check using an if statement, if the seat is currently occupied or not. This thread might help: How to detect seat occupant?

you can try this

local chair = script.Parent -- Assuming the script is placed inside the chair

chair.Changed:Connect(function(att)
	if att == "Occupant" then
		if chair.Occupant ~= nil then
			--do whatever
		end
		
	end
end)
1 Like

yes but how do I detect if its an NPC?

What is the name of the NPC model, assuming that it is a model?

you can check if the Humanoids name is called “NPCHumanoid” (which you should change in the npcs model)

local chair = script.Parent -- Assuming the script is placed inside the chair

chair.Changed:Connect(function(att)
	if att == "Occupant" then
		if chair.Occupant ~= nil then
			if chair.Occupant.Name == "NPCHumanoid" then
				--do whatever
			end
		end
	end
end)

or if you have a specific model,

local chair = script.Parent -- Assuming the script is placed inside the chair

chair.Changed:Connect(function(att)
	if att == "Occupant" then
		if chair.Occupant ~= nil then
			if chair.Occupant.Parent.Name == "NPCNAMEHERE" then
				--do whatever
			end
		end
	end
end)