Are you trying to make all players sit on specific seats? What you can do is put al lthe seats in a folder and do a loop for every seat there and if the sit is not occupied, make a player sit there and remove from from the list
local players = {}
for i,v in pairs(game.Players:GetPlayers()) do
table.insert(players,v.Name) -- insert player names to table
end
for _,seat in ipairs(workspace.TableArea.Chairs:GetChildren()) do
if seat:IsA("Seat") and not seat.Occupant then -- if the seat is a seat and doesn't have anyone on it
local playerchosen = math.random(1,#players)
local chosenchar = workspace:FindFirstChild(playerchosen)
seat:Sit(chosenchar.Humanoid)
table.remove(players,playerchosen)
end
end
This code will loop through all the chairs and if they don’t have anyone on them (checked by seat.Occupant, which if there’s someone on it, it’s set to the humanoid of whoever is sitting on it), it makes a local varaible that gets a random number between 1 and how many players are in game, then it makes a person in the players table sit there, then removes from the table so they can’t be chosen them. Hopefully this works for how you wanted it since I haven’t tested it out myself, but it should,I think
The variable at first is empty, but then contains every player that is in the game currently, and when a player form that list is seated, their name is removed from the table, since it contains the names of the players ingame. This code will probably need to be in an event since this will only run once, so perhaps make a bindableevent (correct me if i’m wrong), that you can fire everytime you want a game to start
Again like I said this code will as soon as the server is made, so it’ll get the players immediately, you’d have to put it somewhere in an event that only runs that code when you tell it to run, cause when the server is ran, there’s no players at the start so the table will stay empty and the reason why that line errored
Alright, I’m not sure how you can make an Event that you can run yourself whenever, but it’s definitely not a RemoteEvent if you were thinking that, it’s probably a BindableEvent