Minigame type of script

Hey Developers.

I am currently making a game and working myself hard on it, and at the moment i need to make the main scripts wich is kind of a minigame script.

Basically i need to do this:

  1. :racing_car: Rounds System

  2. :world_map: Map Voting Screen

  3. :shield: Last one Standing wins

  4. :repeat: Repeat

What i need help is how to make all those things, i have an idea but i’m not sure if it’ll work and i don’t want to waste a lot of time doing something and not working at then end.
Also i wish on adding multiple gamemodes but they all end with the last person standing so if you include how to make multiple gamemodes i would appreciate.

If anyone wants more information i am open for questions, thanks! :slightly_smiling_face:

2 Likes

What do you mean with “Rounds System”?

Last one standing is just putting every player in a table, teleporting them if they got a character otherwise waiting a limited time on them, then putting functions on every one of them with a connection;
Every time one person dies you go through the table and remove them from it and at the same time detect if only one player is still standing, if they still are alive after 
 seconds then he won.

For it to repeat, you would have every minigame’s name / function to make it start inside an array and do something like

if #miniGamesArray >= 1 then
    miniGamesArray[math.random(1, #miniGamesArray)]
end

Then the map voting is just making the players be able to vote between a certain amount of maps or every map, I suggest the first option. Then you send a message to every client and make a GUI pop-up with all the map thumbnails, then once a player clicks on it it sends a message to the server.
You can either make it so that their vote is locked or they can change vote.
Another thing, is being able to see what everyone voted, at the end (like in among us) or not and only the winning map.

1 Like

With round system i just mean that the cycle repeats itself, not much there

I really appreciate your response, but for the Last one Standing part, could you give just a bit more information about it?

Do you mean the map voting?

If yes then, what you should choose between

  1. Locking in votes (not being able to change your vote) or being able to change your vote.
  2. See the player amount of who voted for this map, see at the end who voted for what/the amount of votes or only tell the players which map won the vote (without telling them the amount of votes).
    2.1. An idea is something like among us for the first and second option, showing the player’s avatar pictures in an ImageLabel or characters in a ViewportFrame.
  3. Let them vote every map or let them vote X randomized maps, with X < #Maps.
1 Like

I meant more information about the “Last one Standing” part. That’s the part i’m having more trouble comprehending (sorry if i wrote that wrong). I just want more clear information on how i can do the last one standing part.

I believe this video may come in handy for the Rounds System

1 Like

https://www.youtube.com/watch?v=32dQJZjMsYU Also this.

Absolutely, i’m watching that. Now i just need the “Last one Standing” part of the script to determine when players win.

Did a bit of searching around and found this

I couldn’t tell you if it worked or not because I haven’t tested it.

local playersingame = {};

-- a utility function to remove a player from playersingame by value, rather than key
local removeplayer = function(player)
    for a, x in pairs(playersingame) do
        if(x == player)then
            table.remove(playersingame, a);
        end
    end
end

-- round start
for a, x in pairs(game.Players) do
    -- insert all players into the game
    table.insert(playersingame, x);
end

-- register a function to be called by any player in-game who dies
for a, x in pairs(playersingame) do
    local death;
    death = x.Character.Humanoid.Died:connect(function()
        death:disconnect();
        x.Team = game.Teams.Out;
        removeplayer(x);
    end)
end

-- ... do whatever you have to do to setup the game

-- main game loop
while wait() do
    -- since this is the game loop, we should check whether more than 1 player is left
    -- if not, then the game is over
    if(#playersingame == 1)then
        print("Round is over! " .. playersingame[1].Name .. " won!");
        playersingame = {};
        break;
    elseif(#playersingame < 1)then
        print("Round is over! It's a draw!");
        playersingame = {};
        break;
    end
    -- if we make it to this point, the game is still ongoing
    -- do game stuff
end

-- round ended; reset the script by reenabling it from another script (or rewrite this code as a function)
script.Disabled = true;

The problem with that is that it doesn’t teach me how to use it or implement in my game

Alright, so you would put all the stuff in a while true do loop, as you want it to repeat.
You would simply make a for i loop for the Rounds-System.
For the Map Voting Screen, you would just tween a gui onto the screen, make a table, check if the guy who is trying to click an option has already voted, if no, then add one vote to that variable/intValue.

The last one standing part will be the hardest, probably.
I’d assign a value to all of the player’s character (as when you die, your character gets resetted which means that value will get removed) and then check every second (you can do that inside of the for i loop) who has those values inside of their characters. If it’s only one player, then he is the winner.

You shouldn’t worry that much about the spawns, you’d just make a lobby and add some spawns to it, whenever the round starts, you’d just iterate through all the players and set their HumanoidRootPart’s position to the map. After they die, they would spawn in the lobby.

1 Like

Use these:
CFrame’s
math.random
while true do or while wait(1) do
if 
 > number then
repeat and until
for i = number,secondnumber,thirdnumber do
local players = game.Players:GetChildren()
for i = 1,#players do

(I cant actually send a hole entire script for you to copy but, this might help you.)

2 Likes

Oh yes, sorry I thought you were talking about a BasePart, what you should do is the following:

  1. Put every playerObject in a array.
local alive = game:GetSerivce("Players"):GetPlayers()
  1. Go through the table with a for loop
local function checkForWin(table)
    if #table == 0 then return end -- check if 0 players are alive
    if #table > 1 then return end -- check if the player amount isn't higher than 1
    wait(.5)
    if #table == 0 then return end -- check if the player really didn't die
    return table[1]
end

for index,player in pairs(alive) do
    if not player.Character then -- it might has to be player:FindFirstChild("Character") 
        table.remove(index,alive) 
    end
    player.Character.Died:Connect(function()
        table.remove(index,alive) -- this might fail as the player's index migh've changed if he had index 2 and index 1 died.
    end)
    spawn(function() -- so the for loop doesn't have to wait for this.
        local winPlayer = checkForWin(alive)
    
        if winPlayer  ~= nil then
            print(winPlayer.Name.." has won!")
        end
    end)
end
1 Like