Check if seat is occupied script not working

Hello, so I’ve been making this test script so when the seat is occupied the test part becomes visible and if it isn’t occupied it becomes invisible. Not sure why this is not working:

local testPart = script.Parent.TestPart
local seat = script.Parent.StaffSeat

while wait(1/3) do
	if seat.Occupant == not nil then
		testPart.Transparency = 0
		testPart.Transparency = 1

If anyone can help me, thanks!

1 Like

Hello, instead of using “seat.Occupant == not nil” try using if seat.Occupant then

1 Like

Didn’t expect it to be that simple! Thanks!

No problem, another tip to make your script a little more optimized is instead of putting the code in a loop trying putting it in a function like this: