Trying to change attribute values from a table

i have a script that when u spawn in the game, u will be sat down in a seat. each seat has an attribute called “taken” and i want the taken attribute to be set to true when the player sits down ty!

script:

local seats = game.workspace.seats

-- Table to hold the chair variables, and if they're taken or not
local seatStatus = {
	{chair = seats.seat1, taken = seats.seat1:SetAttribute("taken", false)},
	{chair = seats.seat2, taken = seats.seat2:SetAttribute("taken", false)},
	{chair = seats.seat3, taken = seats.seat3:SetAttribute("taken", false)},
	{chair = seats.seat4, taken = seats.seat4:SetAttribute("taken", false)},
	{chair = seats.seat5, taken = seats.seat5:SetAttribute("taken", false)},
	{chair = seats.seat6, taken = seats.seat6:SetAttribute("taken", false)},
	{chair = seats.seat7, taken = seats.seat7:SetAttribute("taken", false)},
	{chair = seats.seat8, taken = seats.seat8:SetAttribute("taken", false)},
	{chair = seats.seat9, taken = seats.seat9:SetAttribute("taken", false)},
	{chair = seats.seat10, taken = seats.seat10:SetAttribute("taken", false)},
}



function seatPlrs(plr:Player)
	
	local char = plr.Character or plr.CharacterAdded:Wait()
	local hum:Humanoid = char:FindFirstChildOfClass("Humanoid")
	local hrp = char:WaitForChild("HumanoidRootPart")

	hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

if hum then

for i, seat in pairs(seatStatus) do
			if seat.taken == false then 
seat.chair:Sit(hum)
				seat.taken = true

--if seat.chair.Occupant then
--				hum.JumpHeight = 0
--				hum.JumpPower = 0
--				end

break

			else
			end	
			end
end
end

game.Players.PlayerAdded:Connect(seatPlrs)
local seats = game.workspace.seats

-- Table to hold the chair variables, and if they're taken or not
local seatStatus = {
{chair = seats.seat1, taken = seats.seat1:SetAttribute("taken", false)},
{chair = seats.seat2, taken = seats.seat2:SetAttribute("taken", false)},
{chair = seats.seat3, taken = seats.seat3:SetAttribute("taken", false)},
{chair = seats.seat4, taken = seats.seat4:SetAttribute("taken", false)},
{chair = seats.seat5, taken = seats.seat5:SetAttribute("taken", false)},
{chair = seats.seat6, taken = seats.seat6:SetAttribute("taken", false)},
{chair = seats.seat7, taken = seats.seat7:SetAttribute("taken", false)},
{chair = seats.seat8, taken = seats.seat8:SetAttribute("taken", false)},
{chair = seats.seat9, taken = seats.seat9:SetAttribute("taken", false)},
{chair = seats.seat10, taken = seats.seat10:SetAttribute("taken", false)},
}



function seatPlrs(plr:Player)
	
local char = plr.Character or plr.CharacterAdded:Wait()
local hum:Humanoid = char:FindFirstChildOfClass("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")

hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

if hum then

for i, seat in pairs(seatStatus) do
if seat.taken == false then 
seat.chair:Sit(hum)
	seat.taken = true
        seat:SetAttribute("taken", true) -- this line has been added
--if seat.chair.Occupant then
--				hum.JumpHeight = 0
--				hum.JumpPower = 0
--				end

break

else
end	
end
end
end

game.Players.PlayerAdded:Connect(seatPlrs)```

hello fire, tysm 4 the reply. i got the taken attribute to work when they get on the seat but when they get off, i want the taken attribute to be false. i cant get it to change to false tho.

script:

local seats = game.workspace.seats

-- Table to hold the chair variables, and if they're taken or not
local seatStatus = {
	{chair = seats.seat1},
	{chair = seats.seat2},
	{chair = seats.seat3},
	{chair = seats.seat4},
	{chair = seats.seat5},
	{chair = seats.seat6},
	{chair = seats.seat7},
	{chair = seats.seat8},
	{chair = seats.seat9},
	{chair = seats.seat10},
}

function seatPlrs(plr:Player)

	local char = plr.Character or plr.CharacterAdded:Wait()
	local hum:Humanoid = char:FindFirstChildOfClass("Humanoid")
	local hrp = char:WaitForChild("HumanoidRootPart")

	hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

	if hum then

		for i, seat in pairs(seatStatus) do
			--if seat.chair.Occupant then
			--				hum.JumpHeight = 0
			--				hum.JumpPower = 0
			--				end
			seat.chair:Sit(hum)
			if seat.chair.Occupant then
				seat.chair:SetAttribute("taken", true)
			elseif seat.chair.Occupant == nil then
				seat.chair:SetAttribute("taken", false)
			end
			break
		end
	end	
end

game.Players.PlayerAdded:Connect(seatPlrs)

ok basically you need to understand you need to initizalize the seats (only if it’s a serverscript)
Seat:GetPropertyChangedSignal(“Occupant”):Connect(function() basically you need to use that
so you need a loop to get all the seats then when the signal of occupant is changed you need to look if the occupant is == to nil then you need the same script i gave u just change the attribute from false to true that’s all don’t forget to call the intizalizefunction