How To Get All Objects From A Table

This Is The Main Script:

local ReplicatedStorage = game:WaitForChild("ReplicatedStorage")
local ServerStorage = game.ServerStorage
local Maps = game.ServerStorage.Maps:GetChildren()
local Rep = game.ReplicatedStorage
local Status = Rep:WaitForChild("Stats")
local Gamemanager = Rep:WaitForChild("Gamemanager")
local Mapname = Rep:WaitForChild("MapName")
local Weapons = ServerStorage:WaitForChild("Weapons")
local Teams = game:WaitForChild("Teams")
local InGame = Teams["In Game"]
local InLobby = Teams["In Lobby"]
local Winners = ReplicatedStorage:WaitForChild("Winners")
local List = {}

while true do
	for i,v in pairs(Teams["In Game"]:GetPlayers()) do
		v.leaderstats.Wins.Value = v.leaderstats.Wins.Value + 1
		table.insert(List,v.Name)
		Winners:FireAllClients(List)
	end
	for i,v in pairs(game.Players:GetPlayers()) do
		v.Team = InLobby
	end

	Gamemanager:SetAttribute("IsIntermision",true)
	Gamemanager:SetAttribute("IsGameProgress",false)
	Status.Value = "Intermision: "
	if Gamemanager:GetAttribute("IsIntermision") == true and Gamemanager:GetAttribute("IsGameProgress") == false then
		for i = 16,1,-1 do
			Gamemanager:FireAllClients(i)
			wait(1)
		end
	else
		Gamemanager:SetAttribute("IsGameProgress",true)
	end
	Gamemanager:SetAttribute("IsIntermision",false)
	Gamemanager:SetAttribute("IsGameProgress",true)


	local MapSelected = Maps[math.random(1,#Maps)]
	MapSelected:Clone().Parent = workspace
	curent = MapSelected.Name

	Mapname.Value = curent

	print(curent.." Is The Map Selected")
	for _,plr in pairs(game.Players:GetChildren()) do
		for _, Weapons in pairs(game.ServerStorage.Weapons:GetChildren()) do
			Weapons:Clone().Parent = plr.Backpack
		end
		if Gamemanager:GetAttribute("IsIntermision") == false and Gamemanager:GetAttribute("IsGameProgress") == true then
			plr.Character.HumanoidRootPart.CFrame = workspace.WhereTo.CFrame
		else

		end
	end
	Status.Value = "Time Remaining: "
	for i,v in pairs(game.Players:GetPlayers()) do
		v.Team = InGame
	end

	if Gamemanager:GetAttribute("IsGameProgress") == true and Gamemanager:GetAttribute("IsIntermision") == false then
		for i = 31,1,-1 do
			Gamemanager:FireAllClients(i)
			wait(1)
		end
	else
		Gamemanager:SetAttribute("IsIntermision",true)
	end
	workspace[curent]:Destroy()
	Mapname.Value = ""

	for _, plr in pairs(game.Players:GetChildren()) do
		if Gamemanager:GetAttribute("IsGameProgress") == true and Gamemanager:GetAttribute("IsIntermision") == false then

			for _,WeaponBack in pairs(plr.Backpack:GetChildren()) do
				WeaponBack:Destroy()
			end
			if plr.Character == nil or plr.Character.HumanoidRootPart == nil then
				Gamemanager:SetAttribute("IsIntermision",true)
				Gamemanager:SetAttribute("IsGameProgress",false)
			else
				plr.Character.HumanoidRootPart.CFrame = workspace.Lobby.SpawnLocation.CFrame
			end
		else
			warn("Cannot StartGame")
			Gamemanager:SetAttribute("IsGameProgress",false)
			Gamemanager:SetAttribute("IsIntermision",true)
		end
	end
end

Use table.find(table, value) to get the index of the value in the parsed table.

But A All Objects In The Table Is String. Strings Of Players in The Winners Team

table.find(table, Player.Name)index (position in table) or nil (if the name isn’t in the table)

1 Like

Oh I am Sorry This Is The Title : How To Get All Objects From A Table

would a for loop be suitable? If they are string and you need to find the string, just use :FindFirstChild(string)

1 Like

How?

local Ingame = {}

--local script
script.Parent.Text = Ingame:FindFirstChild(String)

Is That It?

local Ingame = {}

for _, value in pairs(Ingame) do
	-- do something with the value here
end
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.