Here is the code where the error is
for i,v in pairs(SortedTributes) do --I have the table already
announce("District "..i..": "..v[1].Name..", and "..v[2].Name.."!")
wait(1)
end
Here is the code where the error is
for i,v in pairs(SortedTributes) do --I have the table already
announce("District "..i..": "..v[1].Name..", and "..v[2].Name.."!")
wait(1)
end
Here is the full code
--[[{Tables}]]
local reaped = {}
local tributes = {}
local tributesDead = {}
local tributesAlive = {}
SortedTributes = {{},{},{},{},{},{},{},{},{},{},{},{},{}}
-----------------------------------------------------
--[[{Variables}]]
local previousVictor = "No One!"
local arenaBiome = "???"
local stage = "???"
local num = game.Players.NumPlayers
local min_players = 2
local asset = "http://roblox.com/asset/?id="
localbadge = game:GetService("BadgeService")
local year = 1
local center = CFrame.new(0, 6.99, 0)
----------------------------------------------------
--[[{Leaderstats}]]
game.Players.PlayerAdded:connect(function(plr)
local gui = game.ReplicatedStorage.Announce:Clone(); gui.Parent = plr.PlayerGui
local ov = Instance.new("ObjectValue", plr); ov.Name = "leaderstats"
local wins = Instance.new("NumberValue", ov); wins.Name = "Wins"
local nv =Instance.new("NumberValue",ov); nv.Value = 0; nv.Name="SP"
end)
---------------------------------------------------
--[[{Side functions}]]
function Cannon()
script.Cannon:Play()
end
function Anthem()
game.Workspace.PanemAnthem:Play()
end
function Updates()
local updates = game.Workspace.Lobby:FindFirstChild("Updates")
--[[Properties]]--
--Velocity edits
updates.BodyAngularVelocity.angularvelocity = Vector3.new(0, 1, 0)
updates.BodyAngularVelocity.maxTorque = Vector3.new(4000, 4000, 4000)
updates.BodyAngularVelocity.P = 1250
--Position edits
updates.BodyPosition.D = 1250
updates.BodyPosition.maxForce = Vector3.new(400000, 400000, 400000)
updates.BodyPosition.P = 10000
updates.BodyPosition.position = Vector3.new(5.833, 458.752, 7.948)
--[[Printing]]--
print("The Update's position is Good!")
end
function CreatePeds()
local peds = Instance.new("Model", game.Workspace); peds.Name = "Pedestals"
for i = 1,24,1 do
local p = Instance.new("Part", peds)
p.Anchored = true
p.Locked = true
p.Size = Vector3.new(6,1,6)
p.BrickColor = BrickColor.new("Mid gray")
p.Name = ("Ped"..i)
p.TopSurface = "SmoothNoOutlines"
p.BottomSurface = "SmoothNoOutlines"
p.CFrame = center*CFrame.Angles(0, i/24*math.pi, 0)*CFrame.new(-115, -0.8, 0)
Instance.new("CylinderMesh", p)
local pa = p:Clone()
pa.Parent = p
pa.Locked = true
pa.Name = "PedPart"
pa.TopSurface = "SmoothNoOutlines"
pa.BottomSurface = "SmoothNoOutlines"
pa.Size = Vector3.new(5,2,5)
pa.CFrame = center*CFrame.Angles(0, i/24*math.pi, 0)*CFrame.new(-115, -1, 0)
pa.BrickColor=BrickColor.new("Dark stone grey")
wait(0.1)
end
end
function announce(text)
game.Workspace.Announcement.Value = text
print("Announcement: "..text)
end
------------------------------------------------------------------
--{[[Main game functions]]}
Updates()
CreatePeds()
--[[Announcing]]
while wait() do
if game.Players.NumPlayers < 2 then
announce("Need 1 More Player to Start!")
wait(3)
announce("Invite Some Friends!")
wait(3)
--Specifying years
elseif game.Players.NumPlayers >= 2 then
game.Workspace.GameStatus.Value = "Reaping"
local lastdig = tostring(year):sub(tostring(year):len())
if lastdig == "1" then
year = (tostring(year).."st")
elseif lastdig == "2" then
year = (tostring(year).."nd")
elseif lastdig == "3" then
year = (tostring(year).."rd")
elseif lastdig >= "4" or lastdig == "0" then
year = (year.."th")
end
--Anouncing
announce("Welcome to the "..year.." Annual Hunger Games!")
wait(3)
announce("And May the odds be ever in your Favor!")
wait(3)
announce("Tributes are being Reaped...")
wait(3)
announce("")
break
end
end
--[[Waiting]]
repeat wait() until game.Workspace.Announcement.Value == ""
--[[Reaping]]
game.Workspace.Start.Value = true
if game.Workspace.Start.Value == true then
print("Starting the "..year.." Annual Hunger Games!")
--Main reaping
if game.Players.NumPlayers > 24 then
for i = 1,24 do
local plrs = game.Players:GetPlayers()
local ranPlayer = (plrs[math.random(1,#plrs)])
for a,b in pairs(tributes) do
if b.Name ~= ranPlayer.Name then
table.insert(tributes,ranPlayer)
else
repeat
ranPlayer = plrs[math.random(1,#plrs)]
until
ranPlayer.Name ~= b.Name
table.insert(tributes,ranPlayer)
end
end
end
else
for a,b in pairs(game.Players:GetPlayers()) do
table.insert(tributes,b)
end
end
--Inserting values
for i,v in pairs(tributes) do
stat = Instance.new("StringValue", v); stat.Value = "Tribute"
end
--Grouping tributes
local currentTab = 1
local seminum = 0
for i,v in pairs(tributes) do
seminum = seminum + 1
if seminum == 3 then
seminum = 0
currentTab = currentTab + 1
end
table.insert(SortedTributes[currentTab],v)
end
--Announcing tributes
for i,v in pairs(SortedTributes) do
announce("District "..i..": "..v[1].Name..", and "..v[2].Name.."!")
wait(1)
end
--Teleporting tributes
Anthem()
for i,v in pairs(tributes) do
v.Character.Torso.CFrame = CFrame.new(game.Workspace.Pedestals:FindFirstChild("Ped"..i).Position + Vector3.new(0,3,0))
end
end
Use: announce("District "..i..": "..SortedTributes[i].Name..", and "..SortedTributes[i + 1].Name.."!") and use: SortedTributes = {}
This discussion is preserved as it was. New answers, comments, and votes are closed.
6 comments
the table must be empty
Sadly, you can't do it that way. I can post a different method. Mind explaining what SortedTributes is?
Im making a Hunger Games game and I want 24 random people to insert into that table when they are reaped
What line does the error appear on/
Is SortedTributs players?
the announcing line