Hello, I am trying to make a pool so player's can vote for a map but i got into a problem where three ( or less) of them get the names changed but a random one(or more) doesn't.. I can't find the solution could someone help me?
for i,v in pairs(game.ReplicatedStorage.Assets.MapVote:GetChildren()) do local RandomMap = Maps[math.random(1,#Maps)] if RandomMap.UsedFV.Value ~= true then if v:IsA("ImageButton") then v.MapName.Text = RandomMap.Name RandomMap.UsedFV.Value = true end end end
There is a possibility of your code repeating the same map twice. What you could do is create an array containing all the maps, then as you choose a map remove it from the array so that the next iteration can't pick the same map.
local Maps = {'A', 'B', 'C', 'D', 'E'} for i = 1, 4 do local Index = math.random(#Maps) print(Maps[Index] table.remove(Maps, Index) end