Hi, I have been working on a party system where I store players through tables and teleport them all at the same time.
local Remotes = game.ReplicatedStorage:WaitForChild("Y_RE")
local Functions = game.ReplicatedStorage:WaitForChild("Y_RF")
local Template = game.ServerStorage:WaitForChild("Y_ServerStorage"):FindFirstChild("Template")
local Create = Functions:WaitForChild("Create")
local Join = Functions:WaitForChild("Join")
local Show = Remotes:WaitForChild("Show")
local Leave = Remotes:WaitForChild("Leave")
--Create
Create.OnServerInvoke = function(Player, Difficulty, MaxPlayers)
if Player then
local PlayersTable = {}
addList(Player, PlayersTable, Difficulty, MaxPlayers)
addPlayers(Player, PlayersTable)
print("Success Create")
return "Success"
else
return "Error"
end
end
Join.OnServerInvoke = function(Player, Server)
end
function addList(Player, Table, Difficulty, MaxPlayers)
local Max = tonumber(MaxPlayers)
if Max > 10 then
Max = 10
elseif Max < 1 then
Max = 1
elseif Max >= 1 and Max <= 10 then
--nothing lol
else
error("Error Max", Max)
end
print("addingList")
for index, Players in pairs(game.Players:GetPlayers()) do
local YGUIS = Players.PlayerGui:WaitForChild("Y_GUIS")
local Debug = Players.PlayerGui:WaitForChild("Debug")
local Select = YGUIS:WaitForChild("Server_Select") or Debug:WaitForChild("Server_Select")
local TemplateClone = Template:Clone()
table.insert(Table, Player)
TemplateClone.Name = Difficulty.." "..Player.Name
TemplateClone.NameLabel.Text = Difficulty.." "..Player.Name
TemplateClone.MaxPlayers.Value = Max
TemplateClone.Creator.Value = Player.Name
TemplateClone.Parent = game.ReplicatedStorage:WaitForChild("Y_Servers")
TemplateClone.Players.Value = 1
local TemplateClone2 = TemplateClone:Clone()
TemplateClone2.Parent = Select.List
print("addedList")
end
end
function addPlayers(Player, Table)
for index, Players in pairs(game.Players:GetPlayers()) do
if Player then
if Players then
local YGUIS = Players.PlayerGui:WaitForChild("Y_GUIS")
local Debug = Players.PlayerGui:WaitForChild("Debug")
local Server = YGUIS:WaitForChild("Server") or Debug:WaitForChild("Server")
local Template = Server:WaitForChild("Template")
for i, v in pairs(Table) do
if v then
print("addingPlayers", Player.Name.." List: ", v, "Amount: "..i)
print("Progressing", i)
local TemplateClone = Template:Clone()
local PlayerIcon = game.Players:GetUserThumbnailAsync(Player.userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
TemplateClone.Name = i.." "..v.Name
TemplateClone.Parent = Server.List
TemplateClone.NameLabel.Text = v.Name
TemplateClone.ImageLabel.Image = PlayerIcon
TemplateClone.Visible = true
print("addedPlayers")
else
error(Player.Name)
end
end
end
end
end
end
Obviously I am not an expert at this, so I legit have no idea how I should store players that have joined.
But when I test in in two players this is the result.
I thought the problem was when I was trying to get the table index or I could’ve been wrong.
And this is what happens when you create another party but in player2’s perspective.
They get mixed up.