Minigame Winning System

I am making a minigame game, and obviously it has a winning system. I’m a bit stumped, however, on how I should approach this. Each minigame has different winning conditions (last player standing, last team standing, etc.).

How would you recommend I write a system for this?

1 Like

This is how I would implement a system like this:

For the last player standing, you’d need to store an array of players and remove them one-by-one if they’ve died, got eliminated, etc. The last player that remains in the array is the winner of that round.

Last team standing is a bit more complicated. You have to store multiple arrays depending on how many teams you have, and remove the player from the array corresponding to the team if they’ve died. If one or more players on a certain team remain after the rest of teams have died off, then they’re the winner of that round.

3 Likes

This doesn’t answer my question?

Since you have different winning conditions for each minigame, I would recommend making a bindable event for when the game ends. No matter what game mode it is or what the condition was for someone to win, it calls the same event that resets the game. You can also pass an array of players that won the minigame through the bindable event and it can distribute points to the players respectively.

What I’ve actually been doing is using ModuleScripts that store all my functions.

I’ve done some reading on BindableEvents, and it seems like functions through a ModuleScript can do the same thing. Is there a difference?

To be honest, I am not really familiar with ModuleScripts but from what I have seen, you may be able to something similar.

Ah alright. Thanks! How would you recommend I write the winning conditions?

How are you separating the code that runs for each gamemode?

What do you mean? Which part? Like the winning conditions?

For each mini game, I am assuming there are different events that happen, right?

I have a modulescript full of code to setup voting, spawn in players, etc. Then for each minigame I have a single script to run any minigame code(there’s not much).

A nice and tidy way to go about this is to create a module containing all of the minigame’s data, such as how the game performs and the duration of the round, etc. In each minigame module, you can create a value that represents different gamemodes such as Last Player Standing and Team Standing, etc. You can represent this in a variety of ways such as numbers or strings.

winning conditions like a code like this

for timer = 300,0,-1 do
    wait(1)
    YOUR_VALUE.Value = timer
end

-- loop through all of them and check values
for _, Player in pairs(game.Players:GetPlayers()) do
    if Player["YOUR_FOLDER_STORAGE_NAME"]["YOUR_VALUE_NAME"].Value == YOUR_CONDITION then
        -- do some stuff here
    end
end

this loops through every player after the timer and after this do some event stuff on the script

I would put the win conditions in the script for the minigame which then calls the general round reset in the main module script.

1 Like