hello! i have a seat script and i want to skip the seat if a player is in it so that it’ll find the next empty seat.
issue:
its sending the players to the same seat even if the attribute “occupied” is true.
script:
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
for i, plr in ipairs(game.Players:GetPlayers()) do
local hum:Humanoid = plr.Character.Humanoid
for seatModelName, seatModel in ipairs(workspace.tableModel:GetChildren()) do
if seatModel.Name == "table" then continue end
if seatModel:IsA("Model") then
for seatName, seat:Seat in ipairs(seatModel:GetChildren()) do
if seat:IsA("Seat") then
if seat:GetAttribute("occupied", true) then continue end
plr.Character:PivotTo(seat.CFrame* seatOFFSET)
seat:Sit(hum)
if seat.Occupant then
seat:SetAttribute("occupied", true)
end
end
end
end
end
end
end)
end)
end