local Maps = {"Camp", "Factory", "Theater"}
--
function GetRandomMaps()
local AvailableMaps = table.clone(Maps)
local SelectedMaps = {}
while MapTurns.Value >= 4 do -- Original Value = 1
wait()
local RandomMap = AvailableMaps[math.random(#AvailableMaps)]
if MapTurns.Value == 1 then
MapTurns.Value = MapTurns.Value + 1
MapText1.Text = RandomMap
table.insert(SelectedMaps, RandomMap)
table.remove(AvailableMaps, RandomMap)
end
if MapTurns.Value == 2 then
MapTurns.Value = MapTurns.Value + 1
MapText2.Text = RandomMap
table.insert(SelectedMaps, RandomMap)
table.remove(AvailableMaps, RandomMap)
end
if MapTurns.Value == 3 then
MapTurns.Value = MapTurns.Value + 1
MapText3.Text = RandomMap
table.insert(SelectedMaps, RandomMap)
table.remove(AvailableMaps, RandomMap)
end
end
MapTurns.Value = 1
end
--
StartVotingEvent.Event:Connect(GetRandomMaps)
I’m trying to make a Voting System, but when StartVotingEvent gets Fired it doesn’t output any errors into output, but it doesn’t work either.
I’m trying to make it so that the table gets removed after changing MapText so that there wouldn’t be any duplicates.
for i = 1,4 do task.wait()
local RandomMap = AvailableMaps[math.random(#AvailableMaps)]
if not table.find(SelectedMaps, RandomMap) then
table.insert(SelectedMaps, RandomMap)
table.remove(AvailableMaps, table.find(RandomMap))
end
end
function GetRandomMaps()
local AvailableMaps = table.clone(Maps)
local SelectedMaps = {}
for i = 1, 3 do task.wait()
local RandomMap = AvailableMaps[math.random(#AvailableMaps)]
if not table.find(SelectedMaps, RandomMap) then
table.insert(SelectedMaps, RandomMap)
table.remove(AvailableMaps, RandomMap) -- I removed table.find() because it expected table, and got string
if i == 1 then
MapText1.Text = tostring(RandomMap)
elseif i == 2 then
MapText2.Text = tostring(RandomMap)
elseif i == 3 then
MapText3.Text = tostring(RandomMap)
end
end
end
end
This is what I did, but again, no errors in output but it also doesn’t work.
function GetRandomMaps()
local AvailableMaps = table.clone(Maps)
local SelectedMaps = {}
for i = 1, 3 do task.wait()
local RandomMap = AvailableMaps[math.random(#AvailableMaps)]
if not table.find(SelectedMaps, RandomMap) then
table.insert(SelectedMaps, RandomMap)
table.remove(AvailableMaps, RandomMap) -- OutPut: 'remove' (number expected, got string)
if i == 1 then -- Doesn't print the 'if' statements
MapText1.Text = tostring(RandomMap)
elseif i == 2 then
MapText2.Text = tostring(RandomMap)
elseif i == 3 then
MapText3.Text = tostring(RandomMap)
end
end
end
end
Can’t really test prints when there is an error, but before the error occured, the print after the if statements didn’t get printed.