So I scripted the shuffleModes array to assign a random value onto a text label (I’m making a mode voting system, but after I assign a value with the RandomMode variable from the shuffleModes array, I want to remove the RandomMode value from the shuffleMode table but…
Using RandomMode = nil
or table.remove(shuffleModes, RandomMode)
or even shuffleModes[RandomMode] = nil
doesn’t work because RandomMode is a value, not a key.
So how do I delete the RandomMode value and its key from the shuffleModes table after the RandomMode value is assigned to a textLabel in studio?
-- shuffleModes table when completely filled
{
[1] = "FFA",
[2] = "Nothing happening",
[3] = "Teamed"
}
Script in question
for i, choice in pairs(workspace.VotingPlace.Modes:GetChildren()) do
local name = choice.SurfaceGui.ModeName
local voteCounter = choice.SurfaceGui.Votes
local shuffleModes = {}
for gamemode, _ in pairs(round) do
table.insert(shuffleModes, gamemode)
end
local RandomMode = shuffleModes[math.random(#shuffleModes)]
name.Text = RandomMode
-- After this I want to delete 'RandomMode' from the 'shuffleModes' table
end
It is a simple question, yes but I couldn’t find a solution to fix this problem