for some reason im getting invalid argument #2 to ‘random’ (interval is empty)
happens on localRadmap line
function CountVotes()
local SoFar = {nil,0}
local AllTab = {}
local RadMap = AllTab[math.random(1,#AllTab)]
getVotes = script.Vote:getChildren()
for gv=1, #getVotes do
if getVotes[gv].Value > SoFar[2] then
SoFar[1],SoFar[2] = getVotes[gv].Name,getVotes[gv].Value
end
end
for gv=1, #getVotes do
if getVotes[gv].Value == SoFar[2] then
table.insert(AllTab,getVotes[gv].Name)
end
end
RadMap = Maps[RadMap]
PreviousMap = RadMap.Name
RandomMap = RadMap
print("Voting is over, map selected")
pcall(function()
getPlayers = Players:getChildren()
for gp=1, #getPlayers do
getPlayers[gp].PlayerGui.VoteGui.Vote.Visible = false
getPlayers[gp].PlayerGui.VoteGui.Help.Visible = false
getPlayers[gp].PlayerGui.VoteGui.Script.VoteBool.Value = true
end
end)
Since AllTab is an empty table, its length will be zero, which means that you’re giving the math.random function an upper-bound that’s smaller than the lower-bound, which makes no sense and hence the error
I might have figured it out. There was never originally an issue so im trying the 1st copy of it that worked and seeing if it fixes it. If so ill answer back with what my issue was
getVotes = script.Vote:getChildren()
local SoFar = {nil,0}
for gv=1, #getVotes do
if getVotes[gv].Value > SoFar[2] then
SoFar[1],SoFar[2] = getVotes[gv].Name,getVotes[gv].Value
end
end
local AllTab = {}
for gv=1, #getVotes do
if getVotes[gv].Value == SoFar[2] then
table.insert(AllTab,getVotes[gv].Name)
end
end
local RadMap = AllTab[math.random(1,#AllTab)]
RadMap = Maps[RadMap]
PreviousMap = RadMap.Name
RandomMap = RadMap
print("Voting is over, map selected")
pcall(function()
getPlayers = Players:getChildren()
for gp=1, #getPlayers do
getPlayers[gp].PlayerGui.VoteGui.Vote.Visible = false
getPlayers[gp].PlayerGui.VoteGui.Help.Visible = false
getPlayers[gp].PlayerGui.VoteGui.Script.VoteBool.Value = true
end
end)
end
I figured it out. Thank you for the help tho. Had the locals in wrong spots thats all