sure here,
lemme just sorta set the stage so u know where everything is
in replicated storage theres parties RS folder and a event named “RE”
in server script service theres this script
'----------------------------------------------------------CONFIGURATION---------------------------------------------------------
local placeId = 12334067852 --The ID of the place to teleport to
local minQueue = 1 --Minimum amount of players needed to be teleported to the place
local maxQueue = 50 --Maximum amount of players that can be queued in the same lobby
local timeAfterMin = 20 --Time allowed for more players to enter the queue once the minimum amount of queued players is reached
local minMembers = 1 --Minimum players needed to queue
local maxMembers = 12 --Maximum players allowed in one party
local rs = game.ReplicatedStorage:WaitForChild(“PartyRS”)
local re = rs:WaitForChild(“RE”)
local parties = rs:WaitForChild(“Parties”)
local tps = game:GetService(“TeleportService”)
local ms = game:GetService(“MemoryStoreService”)
local queue = ms:GetSortedMap(“QueueStore”)
function findParty(plr)
for i, party in pairs(parties:GetChildren()) do
for x, member in pairs(party.Members:GetChildren()) do
if member.Name == plr.Name then
return party
end
end
end
end
function joinParty(plr, party)
leaveParty(plr)
if party and #party.Members:GetChildren() < party.MaximumMembers.Value then
local membersFolder = party.Members
local memberValue = Instance.new("StringValue")
memberValue.Name = plr.Name
memberValue.Parent = membersFolder
re:FireClient(plr, "JOIN", party)
end
end
function leaveParty(plr)
local currentParty = findParty(plr)
if currentParty then
local members = currentParty.Members:GetChildren()
local memberValue = currentParty.Members[plr.Name]
table.remove(members, table.find(members, memberValue))
if #members > 0 then
if memberValue:FindFirstChild("Leader") then
local newLeader = members[Random.new():NextInteger(1, #members)]
memberValue.Leader.Parent = newLeader
currentParty.Name = newLeader.Name .. "'s party"
end
memberValue:Destroy()
else
currentParty:Destroy()
end
re:FireClient(plr, "LEAVE")
end
end
game.Players.PlayerRemoving:Connect(leaveParty)
re.OnServerEvent:Connect(function(plr, instruction, data)
if instruction == "CREATE" then
if data and tonumber(data) and tonumber(data) >= minMembers and tonumber(data) <= maxMembers then
leaveParty(plr)
local newParty = Instance.new("Folder")
local partyName = plr.Name .. "'s party"
newParty.Name = partyName
local maxValue = Instance.new("IntValue")
maxValue.Name = "MaximumMembers"
maxValue.Value = data
maxValue.Parent = newParty
local membersFolder = Instance.new("Folder")
membersFolder.Name = "Members"
membersFolder.Parent = newParty
local partyActive = true
local function updateQueue()
queue:RemoveAsync(partyName)
if newParty:FindFirstChild("IN QUEUE") and partyActive then
local members = {}
for i, member in pairs(membersFolder:GetChildren()) do
if game.Players:FindFirstChild(member.Name) then
table.insert(members, game.Players[member.Name].UserId)
end
end
queue:SetAsync(partyName, members, 2592000)
end
end
membersFolder.ChildAdded:Connect(updateQueue)
membersFolder.ChildRemoved:Connect(updateQueue)
newParty.Destroying:Connect(function()
partyActive = false
queue:RemoveAsync(partyName)
end)
local memberValue = Instance.new("StringValue")
memberValue.Name = plr.Name
local leaderValue = Instance.new("StringValue")
leaderValue.Name = "Leader"
leaderValue.Parent = memberValue
memberValue.Parent = membersFolder
newParty.Parent = parties
re:FireClient(plr, "JOIN", newParty)
end
elseif instruction == "JOIN" then
if data and parties:FindFirstChild(data) then
joinParty(plr, parties[data])
end
elseif instruction == "LEAVE" then
leaveParty(plr)
elseif instruction == "KICK" then
local plrToKick = data and game.Players:FindFirstChild(data)
if plrToKick then
local currentParty = findParty(plr)
if currentParty and currentParty.Members[plr.Name]:FindFirstChild("Leader") then
local currentPartyOfPlrToKick = findParty(plrToKick)
if currentPartyOfPlrToKick and currentParty == currentPartyOfPlrToKick then
leaveParty(plrToKick)
end
end
end
elseif instruction == "QUEUE" then
local currentParty = findParty(plr)
local currentLeader = nil
for i, member in pairs(currentParty.Members:GetChildren()) do
if member:FindFirstChild("Leader") then
currentLeader = member.Name
end
end
if currentLeader == plr.Name and #currentParty.Members:GetChildren() >= minMembers then
local inQueue = currentParty:FindFirstChild("IN QUEUE")
if inQueue then
queue:RemoveAsync(currentParty.Name)
inQueue:Destroy()
else
local queueValue = Instance.new("IntValue")
queueValue.Name = "IN QUEUE"
queueValue.Parent = currentParty
local members = {}
for i, member in pairs(currentParty.Members:GetChildren()) do
if game.Players:FindFirstChild(member.Name) then
table.insert(members, game.Players[member.Name].UserId)
end
end
queue:SetAsync(currentParty.Name, members, 2592000)
local queueStart = os.time()
while task.wait(1) do
if queueValue then
queueValue.Value = os.time() - queueStart
else
break
end
end
end
end
end
end)
local lastOverMin = tick()
while task.wait(1) do
local success, queuedData = pcall(function()
return queue:GetRangeAsync(Enum.SortDirection.Descending, maxQueue)
end)
if success then
local queuedPlayers = 0
local queuedParties = {}
for i, data in pairs(queuedData) do
local partyName = data.key
local partyMembers = data.value
local amountInParty = #partyMembers
if queuedPlayers < maxQueue and queuedPlayers + amountInParty < maxQueue then
queuedPlayers += amountInParty
table.insert(queuedParties, partyName)
end
end
if queuedPlayers < minQueue then
lastOverMin = tick()
end
if tick() - lastOverMin >= timeAfterMin or queuedPlayers == maxQueue then
for i, party in pairs(queuedParties) do
if parties:FindFirstChild(party) then
local playersToTeleport = {}
for x, member in pairs(parties[party].Members:GetChildren()) do
table.insert(playersToTeleport, game.Players[member.Name])
end
tps:TeleportPartyAsync(placeId, playersToTeleport)
end
end
end
end
end`
in startergui theres a partygui and in that theres this script
local open = script.Parent:WaitForChild("Open")
local main = script.Parent:WaitForChild("Main"); main.Visible = false
local close = main:WaitForChild("Close")
local rs = game.ReplicatedStorage:WaitForChild("PartyRS")
local re = rs:WaitForChild("RE")
local parties = rs:WaitForChild("Parties")
local inParty = nil
function formatSeconds(totalSecs)
local mins = tostring(math.floor(totalSecs / 60))
local secs = tostring(totalSecs - (mins * 60))
if string.len(mins) < 2 then
mins = "0" .. mins
end
if string.len(secs) < 2 then
secs = "0" .. secs
end
local formatted = mins .. ":" .. secs
return formatted
end
function displayPage(requestedPage)
for i, page in pairs(main:GetChildren()) do
if page:IsA("Frame") then
if page.Name == requestedPage.Name then
page.Visible = true
else
page.Visible = false
end
end
end
end
function getAvatar(playerName)
if game.Players:FindFirstChild(playerName) then
local uid = game.Players[playerName].UserId
local image = game.Players:GetUserThumbnailAsync(uid, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
return image
end
end
function displayParties()
for i, partyFrame in pairs(main.PartiesPage.PartiesList:GetChildren()) do
if partyFrame:IsA("Frame") then
partyFrame:Destroy()
end
end
local partyFrames = {}
for i, party in pairs(parties:GetChildren()) do
local partyFrame = script.PartyPageParty:Clone()
table.insert(partyFrames, partyFrame)
local function updatePartyFrame()
partyFrame:WaitForChild("NameLabel").Text = party.Name
local leader = nil
local members = {}
for x, member in pairs(party.Members:GetChildren()) do
if member:FindFirstChild("Leader") then
leader = member.Name
else
table.insert(members, member.Name)
end
end
partyFrame.Leader.Image = getAvatar(leader)
table.sort(members, function(a, b)
return a < b
end)
for x, member in pairs(members) do
local memberImage = script.PartyPageMember:Clone()
memberImage.Image = getAvatar(member)
memberImage.Parent = partyFrame.MembersList
end
partyFrame.NumberOfMembers.Text = #party.Members:GetChildren() .. "/" .. party.MaximumMembers.Value
end
updatePartyFrame()
party.Members.ChildAdded:Connect(updatePartyFrame)
party.Members.ChildRemoved:Connect(updatePartyFrame)
partyFrame.Join.MouseButton1Click:Connect(function()
re:FireServer("JOIN", party.Name)
end)
end
table.sort(partyFrames, function(a, b)
return a.NameLabel.Text < b.NameLabel.Text
end)
for i, partyFrame in pairs(partyFrames) do
partyFrame.Parent = main.PartiesPage.PartiesList
end
displayPage(main.PartiesPage)
end
function displayInParty(party)
local partyFolder = typeof(party) == "string" and parties[party] or party
local function updatePartyFrame()
for i, memberFrame in pairs(main.InPartyPage.MembersList:GetChildren()) do
if memberFrame:IsA("Frame") then
memberFrame:Destroy()
end
end
main.InPartyPage.NameLabel.Text = partyFolder.Name
local leader = nil
local members = {}
for i, member in pairs(partyFolder.Members:GetChildren()) do
if member:FindFirstChild("Leader") then
leader = member.Name
else
table.insert(members, member.Name)
end
end
table.sort(members, function(a, b)
return a < b
end)
local leaderFrame = script.InPartyPageMember:Clone()
leaderFrame.NameLabel.Text = leader
leaderFrame.Avatar.Image = getAvatar(leader)
leaderFrame.Kick.Visible = false
leaderFrame.Parent = main.InPartyPage.MembersList
if leader == game.Players.LocalPlayer.Name then
leaderFrame.BackgroundColor3 = Color3.fromRGB(244, 236, 193)
main.InPartyPage.Queue.BackgroundColor3 = Color3.fromRGB(67, 168, 87)
else
main.InPartyPage.Queue.BackgroundColor3 = Color3.fromRGB(172, 167, 165)
end
for i, member in pairs(members) do
local memberFrame = script.InPartyPageMember:Clone()
memberFrame.NameLabel.Text = member
memberFrame.Avatar.Image = getAvatar(member)
memberFrame.Leader.Visible = false
if member == game.Players.LocalPlayer.Name then
memberFrame.BackgroundColor3 = Color3.fromRGB(244, 236, 193)
end
if leader == game.Players.LocalPlayer.Name then
memberFrame.Kick.Visible = true
memberFrame.Kick.MouseButton1Click:Connect(function()
re:FireServer("KICK", member)
end)
end
memberFrame.Parent = main.InPartyPage.MembersList
end
end
updatePartyFrame()
party.Members.ChildAdded:Connect(updatePartyFrame)
party.Members.ChildRemoved:Connect(updatePartyFrame)
displayPage(main.InPartyPage)
while inParty == party do
if party:FindFirstChild("IN QUEUE") then
main.InPartyPage.Queue.Text = formatSeconds(party["IN QUEUE"].Value)
else
main.InPartyPage.Queue.Text = "Queue"
end
task.wait(0.2)
end
end
function displayCreateParty()
displayPage(main.CreatePage)
main.CreatePage.MaxMembers.Text = ""
end
open.MouseButton1Click:Connect(function()
if main.Visible == false then
main.Visible = true
if inParty then
displayInParty(inParty)
else
displayParties()
end
else
main.Visible = false
end
end)
close.MouseButton1Click:Connect(function()
main.Visible = false
end)
main.PartiesPage.Create.MouseButton1Click:Connect(function()
displayCreateParty()
end)
main.CreatePage.Back.MouseButton1Click:Connect(function()
displayParties()
end)
main.CreatePage.Create.MouseButton1Click:Connect(function()
local maxMembers = tonumber(main.CreatePage.MaxMembers.Text)
if maxMembers then
re:FireServer("CREATE", maxMembers)
end
end)
main.InPartyPage.Leave.MouseButton1Click:Connect(function()
re:FireServer("LEAVE")
end)
main.InPartyPage.Queue.MouseButton1Click:Connect(function()
re:FireServer("QUEUE")
end)
re.OnClientEvent:Connect(function(instruction, party)
if instruction == "JOIN" then
inParty = party
displayInParty(party)
elseif instruction == "LEAVE" then
inParty = nil
displayParties()
end
end)
`