Advertisement
Guest User

again because people can't read devforum posts

a guest
Apr 7th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.29 KB | None | 0 0
  1. --Client
  2.  
  3. --//Services
  4.  
  5. local Players = game:GetService("Players")
  6. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  7.  
  8. --//Variables
  9.  
  10. local Player = Players.LocalPlayer
  11. local Assets = ReplicatedStorage:WaitForChild("Assets")
  12. local Remotes = ReplicatedStorage:WaitForChild("Remotes")
  13. local Parties = Assets:WaitForChild("Parties")
  14. local MyParty = Parties:WaitForChild(Player.UserId.."'s party")
  15. local Events = Remotes.Events
  16. local Functions = Remotes.Functions
  17. local UI = Assets.UI
  18. local GUI = script.Parent
  19. local Main = GUI:WaitForChild("Main")
  20. local Invite = Main.Invite
  21. local InviteCoolDown = false
  22.  
  23. --//Functions
  24.  
  25. local function CheckForPlayersYouMissed()
  26.     for i,player in pairs(Players:GetPlayers()) do
  27.         if Invite:FindFirstChild(player.UserId) == nil and player ~= Player then
  28.             local Template = UI.InviteTemplate:Clone()
  29.             Template.Parent = Invite
  30.             Template.Name = player.UserId
  31.             Template.Text = player.Name
  32.             Template.MouseButton1Click:Connect(function()
  33.                 if not InviteCoolDown then
  34.                     InviteCoolDown = not InviteCoolDown
  35.                     Events:FireServer("Invite",{tonumber(Template.Name)}) -- tell the server they want to invite the player
  36.                     wait(4)
  37.                     InviteCoolDown = not InviteCoolDown
  38.                 end
  39.             end)
  40.         end
  41.     end
  42. end
  43.  
  44. local function FindInTable(index,tbl)
  45.     for i,v in pairs(tbl) do
  46.         if i == index then
  47.             return v
  48.         end
  49.     end
  50. end
  51.  
  52. --//Events
  53.  
  54. Players.PlayerAdded:Connect(function(player)
  55.     if Invite:FindFirstChild(player.UserId) == nil and player ~= Player then
  56.         local Template = UI.InviteTemplate:Clone()
  57.         Template.Parent = Invite
  58.         Template.Name = player.UserId
  59.         Template.Text = player.Name
  60.         Template.MouseButton1Click:Connect(function()
  61.             if not InviteCoolDown then
  62.                 InviteCoolDown = not InviteCoolDown
  63.                 Events:FireServer("Invite",{tonumber(Template.Name)}) -- tell the server they want to invite the player
  64.                 wait(4)
  65.                 InviteCoolDown = not InviteCoolDown
  66.             end
  67.         end)
  68.     end
  69. end)
  70.  
  71. Players.PlayerRemoving:Connect(function(player)
  72.     if Invite:FindFirstChild(player.UserId) ~= nil and player ~= Player then
  73.         Invite:FindFirstChild(player.UserId):Destroy() -- remove their stuff since they left
  74.     end
  75. end)
  76.  
  77. Functions.OnClientInvoke = function(Command,ArgumentTable)
  78.    
  79. end
  80.  
  81. Events.OnClientEvent:Connect(function(Command,ArgumentTable)
  82.     if Command == "AddPlayerToMM" then
  83.         local AddPlayer = ArgumentTable.Player
  84.         local PartyPlace = ArgumentTable.PartyPlace
  85.         Main.Party:FindFirstChild("Player"..PartyPlace).Player.Text = AddPlayer.Name
  86.         Main.Party:FindFirstChild("Player"..PartyPlace).Icon.Image = "https://www.roblox.com/bust-thumbnail/image?userId="..AddPlayer.UserId.."&width=420&height=420&format=png"
  87.         if AddPlayer == Player then
  88.             if PartyPlace == 1 then
  89.                 Main.Ready.Visible = true
  90.             else
  91.                 Main.Ready.Visible = false
  92.                 if Main.Party.Player1.Player.Text == Player.Name then
  93.                     Main.Ready.Visible = true
  94.                 end
  95.             end
  96.         end
  97.     elseif Command == "ENDPARTY" then
  98.         for i,v in pairs(Main.Party:GetChildren()) do
  99.             if v.Name ~= "Player1" then
  100.                 v.Icon.Image = "rbxasset://textures/ui/GuiImagePlaceholder.png"
  101.                 v.Player.Text = "PlayerName"
  102.             else
  103.                 v.Player.Text = Player.Name
  104.                 v.Icon.Image = "https://www.roblox.com/bust-thumbnail/image?userId="..Player.UserId.."&width=420&height=420&format=png"
  105.             end
  106.         end
  107.         Main.Ready.Visible = true
  108.         Main.BadNews.Visible = true
  109.         wait(string.len(Main.BadNews.Text)/20)
  110.         Main.BadNews.Visible = false
  111.     elseif Command == "Invited" then
  112.         local PlayerFrom = ArgumentTable.From
  113.         Main.Invited.Visible = true
  114.         Main.Invited.Message.Text = PlayerFrom.Name.." has invited you to a party, would you like to join?"
  115.         Main.Invited.Yes.MouseButton1Click:Connect(function()
  116.             Main.Invited.Visible = false
  117.             Events:FireServer("AcceptInvite",{From = PlayerFrom,Key = ArgumentTable.InviteID})
  118.         end)
  119.         Main.Invited.No.MouseButton1Click:Connect(function()
  120.             Main.Invited.Visible = false
  121.             Events:FireServer("DeclineInvite",{From = PlayerFrom,Key = ArgumentTable.InviteID})
  122.         end)
  123.     elseif Command == "AddAllToNewParty" then
  124.         local PlayersTable = ArgumentTable.Players
  125.         for i,v in pairs(Main.Party:GetChildren()) do
  126.             local Find = FindInTable(i,PlayersTable)
  127.             if Find ~= nil then
  128.                 if Players:GetPlayerByUserId(tonumber(Find)) == Player then
  129.                     if i == 1 then
  130.                         Main.Ready.Visible = true
  131.                     else
  132.                         Main.Ready.Visible = false
  133.                     end
  134.                 end
  135.             end
  136.             if Find ~= nil then
  137.                 v.Player.Text = Players:GetPlayerByUserId(tonumber(Find)).Name
  138.                 v.Icon.Image = "https://www.roblox.com/bust-thumbnail/image?userId="..Find.."&width=420&height=420&format=png"
  139.             else
  140.                 v.Icon.Image = "rbxasset://textures/ui/GuiImagePlaceholder.png"
  141.                 v.Player.Text = "PlayerName"
  142.             end
  143.         end
  144.     end
  145. end)
  146.  
  147. Main.Ready.MouseButton1Click:Connect(function()
  148.     Events:FireServer("Ready")
  149. end)
  150.  
  151. --//Main
  152.  
  153. Main.Ready.Visible = true
  154.  
  155. CheckForPlayersYouMissed()
  156.  
  157. if MyParty ~= nil then
  158.     if tonumber(MyParty.Party["1"].Value) == Player.UserId then
  159.         Main.Party.Player1.Player.Text = Player.Name
  160.         Main.Party.Player1.Icon.Image = "https://www.roblox.com/bust-thumbnail/image?userId="..Player.UserId.."&width=420&height=420&format=png"
  161.     end
  162. end
  163.  
  164. local CheckIfServerIsReserved = Functions:InvokeServer("IsReserved?")
  165.  
  166. if CheckIfServerIsReserved then
  167.     Main.Visible = false
  168. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement