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

How do you check if a seat is occupied?

Asked by 3 years ago

Hey! I have a seat, and a script, and I want something to happen when the seat becomes occupied. Any help would be apprieciated!

2 answers

Log in to vote
0
Answered by 3 years ago

Using :GetPropertyChangedSignal, what this should do is detect when a player is seated in a seat, and print something.

local seat = script.Parent --get the seat

seat:GetPropertyChangedSignal("Occupant"):Connect(function() --detect when the seat's occupancy has changed
    if seat.Occupant ~= nil then --check if the seat has become vacant or not
        print("Someone is sitting in the seat!") -- if not vacant, print this
    end
end)
0
Thx! :D mine_theblocks 23 — 3y
Ad
Log in to vote
0
Answered by
Xyternal 247 Moderation Voter
3 years ago

You can try using this.

local Seat =  script.Parent -- Path to seat

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
    if Seat.Occupant ~= nil then
        print("something is happening")
    end
end)

Answer this question