Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How come this sitting detector does not function?

Asked by 3 years ago
Edited 3 years ago

--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

Log in to vote
0
Answered by 3 years ago

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)
Ad

Answer this question