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

How come this sitting detector does not function?


--Variables
local seat = script.Parent
local debounce = true
local enabled = false



--Script
local function onTouch(Part)
	if debounce and Part.Parent:FindFirstChild("Humanoid") then
		if Part.Parent.Humanoid.Sit == true then
			debounce = false
			print(Part.Parent, "is sitting")
			
			wait(0.1)

			debounce = true
		end
	end
end

seat.Touched:Connect(onTouch)

Can someone explain why if Part.Parent.Humanoid.Sit == true then doesn't work?

1 answer

✓ Accepted answer

The property probably is set after u check the value. I better option would to use GetPropertyChangedSignal and check for when the seat's Occupant changes.

Seat:GetPropertyChangedSignal('Occupant'):Connect(function()
	-- ok
end)

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