local mapVotes = {} local playerVotes = {} for i, map in pairs(game.ReplicatedStorage.VotedMap:GetChildren()) do table.insert(mapVotes, map.Value) end for i, choice in pairs(game.ReplicatedStorage.VotedPlayers:GetChildren()) do table.insert(playerVotes, choice.Value) end table.sort(mapVotes) table.sort(playerVotes) print(mapVotes) print(playerVotes)
So I've tried to troubleshoot this and I think there's an issue with the for loops. Any ideas?
yes use unpack to print it, unpack will read each string.
EDIT:
instead of print(unpack(mapVotes)) try looping through every string and printing it, if it doesnt work then i dont know what will:
for _,i in pairs(mapVotes) do print(i) end
EDIT: ok im sorry i didnt know they werer int values, int values cant print, everything makes so much sense. Ok its simple. tostring. new code:
for _,i in pairs(mapVotes) do e = tostring(i) print(e) end
i dont know if it works with unpack, try it:
print( tostring( unpack( mapVotes ) ) )
Try a different approach, maybe you made a typo, or an Instance is not defined correctly within the script. Either way, I did re-create the script with new practices that I suggest you use.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local MapVotes = {} local PlayerVotes = {} local VotedMap = ReplicatedStorage:WaitForChild("VotedMap") local VotedPlayer = ReplicatedStorage:WaitForChild("VotedPlayers") for index, value in pairs(VotedMap:GetChildren()) do if value ~= nil and typeof(value) == "Instance" and value:IsA("ValueBase") then table.insert(MapVotes, value.Value) print("Value has been inserted.") end end for index, value in pairs(VotedPlayer:GetChildren()) do if value ~= nil and typeof(value) == "Instance" and value:IsA("ValueBase") then table.insert(PlayerVotes, value.Value) print("Value has been inserted.") end end table.sort(MapVotes) table.sort(PlayerVotes) pcall(print, table.concat(MapVotes, ", ")) pcall(print, table.concat(PlayerVotes, ", "))