Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Set How Many Seats Based Off Player Count?

So basically I have a game called Overbooked. Its kind of like Musical Chairs, there are 10 players and 5 seats, those 5 players that get a seat and will move onto the next round. Next round will have 3 seats and so on. Last round, 1 seat left and the player that gets the seat wins. Lets say we dont have 10 players, and we have 7, I need a script that will detect how many players there are and set a certain amount of seats. So basically something that will check the player count, set the amount of seats and Destroy the ones we dont need. But only if nobody is sitting on the seat. So like if player count = 7 then you know make it so there will be only say 4 seats (I want to be able to customize how many seats there will be).

Im not asking for a script im asking for a way to do it. Like a template, i tried constructing a script but failed. Any help would be appreciated

2 comments

0

scriptinghelpers is not a request site. I suggest doing an i, v in pairs loop.

0

posted an answer buddy!

1 answer

local players = game.Players
local numberOfPlayers = #players
local function findnumberofchairs()
    if (numberOfPlayers % 2 == 0) then
        local numberOfChairs = math.floor(numberOfPlayers / 2)
    elseif not (numberOfPlayers % 2 == 0) then
        local numberOfChairs = math.floor((numberOfPlayers - 1) / 2)
    end
    return numberOfChairs
end
wait()
local NumberOfChairs = findnumberofchairs()

This discussion is preserved as it was. New answers, comments, and votes are closed.