**What do you want to achieve?
so i was making a table with different variety
**What is the issue?
so basically my table have 2 variety call survivor and hunter , i have 2 button that will let you join to survivor or hunter . the issue is i don’t know how to insert the player when there is two variety in a table . here is a script below .
I use something pretty similar in my game, and I just use table.insert(table, plr).
Isn’t it better to have a list of survivors instead? But if you want to keep it like this you can do
but i need to connect this to a teleport system , so i only can make 1 table . also i dont want random join . what i need is when a player press survivor button . there will join to the survivor variety in the table
so i need a matchmaking system , with 2 different teams . you can join them by either pressing survivor or hunter . the reason i use table is cuz i want to tp them to other server .
You can pass data while teleporting a player though, I did not understand what you are trying to do exactly but what I have said may help. Let me know if you want me to explain how to pass data using teleport service.
i know but what i want is make a match first before going to other server . so its more easy .
its like a mobile legend matchmaking system . 2 different variety in 1 table , when they are prepared then they all get teleported to other server .
What I would do is that I would create a StringValue in each player. Based on what button the player presses the StringValue will change to “Survivor” or “Hunter”. Then in the script I would do something like this:
local Players = game:GetService("Players")
local Hunters = {}
local Survivors = {}
for i,v in pairs(Players:GetChildren()) do
if v:WaitForChild("Role").Value == "Survivor" then
table.insert(Survivors,v.Name)
else
table.insert(Hunters,v.Name)
end
end
If this works don’t forget to mark this as a solution
local Players = game:GetService("Players")
local Hunters = {}
local Survivors = {}
for i,v in pairs(Players:GetChildren()) do
if v:WaitForChild("leaderstats").Role.Value == "Survivor" then
table.insert(Survivors,v.Name)
else
table.insert(Hunters,v.Name)
end
end
quick question , i don’t have anyone to help me test out the script . so can you tell me if this is working or not?
local Players = game:GetService("Players")
local Hunters = {}
local Survivors = {}
for i,v in pairs(Players:GetChildren()) do
if v:WaitForChild("leaderstats").Role.Value == "Survivor" then
table.insert(Survivors,v.Name)
else
table.insert(Hunters,v.Name)
end
end
repeat wait() until #Hunters == 1
if #Survivors == 4 then
print("teleport service here , havent type it out yet lol")
end