Know wether seat is occupied using script

So i made a script that runs a code when both player seated on their seat
local boySeat = script.Parent.Boy
local girlSeat = script.Parent.Girl

local franxActivated = false
while wait(1) do
if franxActivated == false and boySeat.Occupant == “Humanoid” and girlSeat.Occupant == “Humanoid” then
print(“Franx Activated”)

	--- Do stuffs here like activating the gui
	franxActivated = true
end

if franxActivated == true and (not boySeat.Occupant == "Humanoid" or not boySeat.Occupant == "Humanoid") then
	franxActivated = false
end

end
but its not working i wonder how can i tell that the seat is occupied rather than this code

To detect if a seat is occupied, you just have to confirm that the Seat.Occupant does not equal nil.

if Seat.Occupant == nil then
    --seat is not occupied
else
    --seat is occupied
end

This code that you created won’t work because Seat.Occupant does not equal the string “Humanoid”, when filled, but rather the Humanoid Instance of the user sitting.

boySeat.Occupant == “Humanoid” --will not work
2 Likes

Not really necessary because .Occupant should typically always return a Humanoid, but you can also just use Seat.Occupant:IsA(“Humanoid”) to verify it’s a humanoid.

This would not hurt in any way. Just make sure to always confirm that the .Occupant isn’t nil first, since :IsA isn’t a function of nil.

1 Like

Sorry I worded my reply in a weird manner. I meant my reply wasn’t really necessary lol.

1 Like