Need Help with Voting system

I want to make a voting system like flicker, where you are guessing who the murderer is.
how would I make this into a list of objects that are in the folder


The player would have a value that is either “Alive” or “NotAlive”
I want it to only count for the players that have a value that says “Alive”,
when the game starts, it puts the string value with “alive” in the folder with the players name as the name of the string value, this is what i have so far:
sdvas

wgrw
I have it so it votes for two options but idk how to make it vote for players

First of all, when you create a game like this, you should make sure that the role of the murderer is saved in the server side (workspace isn’t safe) and that the client will not be able to access it (like a server storage), which will prevent a exploiter from knowing who the murderer is. Secondly, I recommend that you use a boolean (bool) instead of a string to check if the player is “Alive” or “NotAlive” as this would, I think, make development easier. Of course you are free to do what you want. Finally I would advise you to a different approach to fix your issue, instead of taking into account only living players in all votes you could simply prevent dead players from voting witch would mean that all votes would be from alive player from the start

Exemple of a safe emplacement to store a role informations (from a personal game) using the server storage service :

1 Like

You could use attributes for checking if a player is alive.

-- Server Side

--When game starts give everyone alive attribute
for _, player in ipairs(Players:GetPlayers) do -- Players = game:GetService("Players")
   player:SetAttribute("isAlive", true)
end

-- Whenever you want to check who's alive you would create a function
local function getAlivePlayers(): table
   local Alive = {}
   for _, player in ipairs(Players:GetPlayers()) do
      if not player:GetAttribute("isAlive") then continue end
      table.insert(Alive, player)
   end
   return Alive
end

local AlivePlayers = getAlivePlayers()
1 Like

Putting attributes on a player object from the server side can work but you should avoid it for sensive info since it will also replicate to all clients

Yeah I wouldn’t put who the killer is or something I don’t want clients to see. Though this should be fine since your checking if a player is alive or not. You could always use tables instead like so:

-- Server Side
local PlayersAlive: {player} = {}

-- Add players to table
for _, player in ipairs(Players:GetPlayers()) do
   table.insert(PlayersAlive, player)
end

-- Whenever player dies
table.remove(PlayersAlive, table.find(PlayersAlive, player))

-- When you need to get all the players alive
-- You would just use PlayersAlive

It would be a lot more secure, and personally it would be better since clients won’t be able to see if a player is alive or not, so it’s a lot more fair.

How would I add a table into gui

Well once the games over you would just send a remote event to the client and then loop through the table and for each loop Clone some sort of template and add the players name, etc.

1 Like