Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

One or more map poll text is not changing?

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

https://imgur.com/a/RNHUpZ4

1 comment

0

Just looking, you don't need to have the 1 in your math.random(1,#Maps). You just need math.random(#Maps)

1 answer

✓ Accepted answer

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

1 comment

0

Alright i mixed it with my code so it get's all the maps into a table and it works perfectly! thank you for helping me. Now i will don't need to deal with bool values.

This discussion is preserved as it was. New answers, comments, and votes are closed.