So basically I’m looking for a way to make a script which will
If there are 10 players say and I wanted say 5 parts I have a player count value and when it’s 10 remove number amount of parts until there are 5 parts. And if 7 players let’s say 3 parts, vice versa. Let’s say these parts are seats and I want to check if someone is sitting on that seat and not remove it if they are. Here’s some scrap I constructed before which might show you what I’m looking for.
local count = script:FindFirstChild("Players")
local seats = game.Workspace.PlaneSeats
local remainingseats = script:FindFirstChild("RemainingSeats")
game.Players.ChildAdded:Connect(function(player)
count.Value = count.Value + 1
print(count.Value)
if count.Value == 10 then
repeat wait()
if seats.Seat1.SeatPart.Occupant ~= "Humanoid" then
seats.Seat1.Transparency = 1
seats.Seat1.CanCollide = false
seats.Seat1.Archivable = false
seats.Seat1.SeatPart.Disabled = true
remainingseats.Value = remainingseats.Value - 1
elseif seats.Seat2.SeatPart.Occupant ~= "Humanoid" then
seats.Seat2.Transparency = 1
seats.Seat2.CanCollide = false
seats.Seat2.Archivable = false
seats.Seat2.SeatPart.Disabled = true
remainingseats.Value = remainingseats.Value - 1
elseif seats.Seat3.SeatPart.Occupant ~= "Humanoid" then
seats.Seat3.Transparency = 1
seats.Seat3.CanCollide = false
seats.Seat3.Archivable = false
seats.Seat3.SeatPart.Disabled = true
remainingseats.Value = remainingseats.Value - 1
elseif seats.Seat4.SeatPart.Occupant ~= "Humanoid" then
seats.Seat4.Transparency = 1
seats.Seat4.CanCollide = false
seats.Seat4.Archivable = false
seats.Seat4.SeatPart.Disabled = true
remainingseats.Value = remainingseats.Value - 1
elseif seats.Seat5.SeatPart.Occupant ~= "Humanoid" then
seats.Seat5.Transparency = 1
seats.Seat5.CanCollide = false
seats.Seat5.Archivable = false
seats.Seat5.SeatPart.Disabled = true
remainingseats.Value = remainingseats.Value - 1
elseif seats.Seat6.SeatPart.Occupant ~= "Humanoid" then
seats.Seat6.Transparency = 1
seats.Seat6.CanCollide = false
seats.Seat6.Archivable = false
seats.Seat6.SeatPart.Disabled = true
remainingseats.Value = remainingseats.Value - 1
elseif seats.Seat7.SeatPart.Occupant ~= "Humanoid" then
seats.Seat7.Transparency = 1
seats.Seat7.CanCollide = false
seats.Seat7.Archivable = false
seats.Seat7.SeatPart.Disabled = true
remainingseats.Value = remainingseats.Value - 1
elseif seats.Seat8.SeatPart.Occupant ~= "Humanoid" then
seats.Seat8.Transparency = 1
seats.Seat8.CanCollide = false
seats.Seat8.Archivable = false
seats.Seat8.SeatPart.Disabled = true
remainingseats.Value = remainingseats.Value - 1
elseif seats.Seat9.SeatPart.Occupant ~= "Humanoid" then
seats.Seat9.Transparency = 1
seats.Seat9.CanCollide = false
seats.Seat9.Archivable = false
seats.Seat9.SeatPart.Disabled = true
remainingseats.Value = remainingseats.Value - 1
elseif seats.Seat10.SeatPart.Occupant ~= "Humanoid" then
seats.Seat10.Transparency = 1
seats.Seat10.CanCollide = false
seats.Seat10.Archivable = false
seats.Seat10.SeatPart.Disabled = true
remainingseats.Value = remainingseats.Value - 1
end
until remainingseats.Value == 1
print("Done!")
end
end)
game.Players.ChildRemoved:Connect(function(player)
count.Value = count.Value - 1
print(count.Value)
end)

4 comments
Good job, I hope he will take your comment into a count because it's well written. I went with a different approach, I made almost ready code which might help him now but not in the long term as you did.
It cant hurt to post your approach maybe he ll learn something from it too, thanks for the comment
It's just under your post
You was fiew mins faster ;)