Advertisement
Guest User

Untitled

a guest
Aug 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.36 KB | None | 0 0
  1. ---------------
  2. -- Constants --
  3. ---------------
  4.  
  5.  
  6. local LegionsFrame = script.Parent.Parent.Legions
  7. local UniformsFrame = script.Parent.Parent.Uniforms
  8. local MorphsDir =  game.ReplicatedStorage.Morphs
  9. local Libs = game.ReplicatedStorage.Libs
  10. local Divisions = require(Libs.Divisions)
  11.  
  12. local Camera = game.Workspace.CurrentCamera
  13. local Player = game.Players.LocalPlayer
  14. local DevTrooper = script.DevTrooper:Clone()
  15.  
  16. ----------
  17. -- Init --
  18. ----------
  19. repeat wait() until Player.Character
  20.  
  21.  
  22. script.Parent.Parent.Enabled = true
  23.    
  24.    
  25.  
  26.  
  27. ---------------
  28. -- Functions --
  29. ---------------
  30.  
  31. function GiveHelmet(Helmet, BodyPart)
  32.    
  33.     local HelmetClone = Helmet:Clone()
  34.  
  35.     HelmetClone.PrimaryPart = HelmetClone.Middle
  36.     HelmetClone:SetPrimaryPartCFrame(DevTrooper[BodyPart].CFrame)
  37.  
  38.     HelmetClone.Parent = DevTrooper
  39.     DevTrooper.Head:ClearAllChildren()
  40.     DevTrooper.Head.Transparency = 1
  41.    
  42.     for i,v in pairs (HelmetClone:GetChildren())do
  43.         DevTrooper.Humanoid:RemoveAccessories()
  44.         local W = Instance.new("Weld")
  45.         W.Part0 = HelmetClone.Middle
  46.         W.Part1 = v
  47.         local CJ = CFrame.new(HelmetClone.Middle.Position)
  48.         local C0 = HelmetClone.Middle.CFrame:inverse()*CJ
  49.         local C1 = v.CFrame:inverse()*CJ
  50.         W.C0 = C0
  51.         W.C1 = C1
  52.         W.Parent = HelmetClone.Middle
  53.     end
  54.     local W2 = Instance.new("Weld")
  55.     W2.Part0 = DevTrooper[BodyPart]
  56.     W2.Part1 = HelmetClone.Middle
  57.     W2.Parent = DevTrooper[BodyPart]
  58.     for i,v in pairs (HelmetClone:GetChildren())do
  59.         v.Anchored = false
  60.         v.CanCollide= false
  61.     end
  62.  
  63.     if DevTrooper:FindFirstChild("Shirt") then
  64.         DevTrooper.Shirt:Destroy()
  65.     end
  66.     if DevTrooper:FindFirstChild("Pants") then
  67.         DevTrooper.Pants:Destroy()
  68.     end
  69.    
  70.     Helmet.Parent.Shirt:Clone().Parent = DevTrooper
  71.     Helmet.Parent.Pants:Clone().Parent = DevTrooper
  72.  
  73. end
  74.  
  75. function RemoveObjects()
  76.     if DevTrooper:FindFirstChild("Helmet") then
  77.         DevTrooper:FindFirstChild("Helmet"):Destroy()
  78.     end
  79.    
  80.     if DevTrooper:FindFirstChild("Arm1") then
  81.         DevTrooper:FindFirstChild("Arm1"):Destroy()
  82.     end
  83.    
  84.     if DevTrooper:FindFirstChild("Arm2") then
  85.         DevTrooper:FindFirstChild("Arm2"):Destroy()
  86.     end
  87.    
  88.     if DevTrooper:FindFirstChild("Leg1") then
  89.         DevTrooper:FindFirstChild("Leg1"):Destroy()
  90.     end
  91.    
  92.     if DevTrooper:FindFirstChild("Leg2") then
  93.         DevTrooper:FindFirstChild("Leg2"):Destroy()
  94.     end
  95.    
  96.     if DevTrooper:FindFirstChild("Chest") then
  97.         DevTrooper:FindFirstChild("Chest"):Destroy()
  98.     end
  99. end
  100.  
  101. ----------
  102. -- Main --
  103. ----------
  104.  
  105. function RepublicTeam()
  106.     script.Parent.Parent.TeamSelect.Visible = false
  107.     LegionsFrame.Visible = true
  108.     UniformsFrame.Visible = true
  109.    
  110.     Camera.CameraType = "Scriptable"
  111.     Camera.CFrame = game.Workspace.CamPart.CFrame
  112.    
  113.     DevTrooper.PrimaryPart = DevTrooper.Torso
  114.     DevTrooper:SetPrimaryPartCFrame(game.Workspace.DevTrooperSpot.CFrame)
  115.     DevTrooper.Parent = game.Workspace
  116.    
  117.     for i = 1, #Divisions do
  118.         if Player:IsInGroup(Divisions[i].GroupId)or Divisions[i].GroupId == 0 then
  119.             local Button = Instance.new("TextButton")
  120.             Button.Size = UDim2.new(1,0,0,50)
  121.             Button.BackgroundTransparency = 1
  122.             Button.Font = "SourceSans"
  123.             Button.TextSize = 30
  124.             Button.TextXAlignment = "Left"
  125.             Button.TextColor3 = Color3.fromRGB(255,255,255)
  126.        
  127.             Button.Text = Divisions[i].Name
  128.             Button.Parent = LegionsFrame
  129.        
  130.             Button.MouseButton1Click:connect(function ()
  131.                 for i,v2 in pairs(UniformsFrame:GetChildren()) do
  132.                     if v2.ClassName == "TextButton" then
  133.                         v2:Destroy()
  134.                     end
  135.                 end
  136.                 for i,v3 in pairs (MorphsDir[Divisions[i].Name]:GetChildren()) do
  137.            
  138.                     local Allowed = true
  139.            
  140.                     if v3:FindFirstChild("Rank") then
  141.                         if Player:GetRankInGroup(Divisions[i].GroupId) >= v3:FindFirstChild("Rank").Value then
  142.                             Allowed = true
  143.                         else
  144.                             Allowed = false
  145.                         end
  146.                     end
  147.                    if Allowed then
  148.                         local Button2 = Instance.new("TextButton")
  149.                         Button2.Size = UDim2.new(1,0,0,50)
  150.                         Button2.BackgroundTransparency = 1
  151.                         Button2.Font = "SourceSans"
  152.                         Button2.TextSize = 30
  153.                         Button2.TextXAlignment = "Left"
  154.                         Button2.TextColor3 = Color3.fromRGB(255,255,255)
  155.            
  156.                         Button2.Text = v3.Name
  157.                         Button2.Parent = UniformsFrame
  158.            
  159.                         Button2.MouseButton1Click:connect(function ()
  160.                
  161.                             RemoveObjects()
  162.            
  163.                             if v3:FindFirstChild("Leg1") then
  164.                                 GiveHelmet(v3.Leg1, "Left Leg")
  165.                             end
  166.                             if v3:FindFirstChild("Leg2") then
  167.                                 GiveHelmet(v3.Leg2, "Right Leg")
  168.                             end
  169.                             if v3:FindFirstChild("Arm1") then
  170.                                 GiveHelmet(v3.Arm1, "Left Arm")
  171.                             end
  172.                             if v3:FindFirstChild("Arm2") then
  173.                                 GiveHelmet(v3.Arm2, "Right Arm")
  174.                             end
  175.                             if v3:FindFirstChild("Chest") then
  176.                                 GiveHelmet(v3.Chest, "Torso")
  177.                             end
  178.                             if v3:FindFirstChild("Helmet") then
  179.                                 GiveHelmet(v3.Helmet, "Head")
  180.                             end
  181.                             SelectedMorph = v3
  182.                            
  183.                             script.Parent.Parent.Spawn.Visible = true
  184.                         end)
  185.                     end
  186.                 end
  187.             end)
  188.         end
  189.     end
  190. end
  191.  
  192. function RaiderTeam()
  193.     script.Parent.Parent.TeamSelect.Visible = false
  194.     LegionsFrame.Visible = false
  195.     UniformsFrame.Visible = false
  196.     Player.Character.Torso.CFrame = game.Workspace.RaiderSpawn.CFrame  
  197. end
  198.  
  199. script.Parent.Parent.TeamSelect.Republic.MouseButton1Click:connect(function ()
  200.     if Player:IsInGroup(Divisions.MainGroup) then
  201.         RepublicTeam()
  202.     else
  203.         script.Parent.Parent.TeamSelect.Republic.TextLabel.Text = "You are not in the group!"
  204.         wait(2)
  205.         script.Parent.Parent.TeamSelect.Republic.TextLabel.Text = "REPUBLIC"
  206.     end
  207. end)
  208.  
  209. script.Parent.Parent.TeamSelect.Hostiles.MouseButton1Click:connect(function ()
  210.     if Player:IsInGroup(Divisions.MainGroup) then
  211.         script.Parent.Parent.TeamSelect.Hostiles.TextLabel.Text = "You are in the clone group!"
  212.         wait(2)
  213.         script.Parent.Parent.TeamSelect.Hostiles.TextLabel.Text = "CIS"
  214.     else
  215.         RaiderTeam()
  216.     end
  217. end)
  218.  
  219. script.Parent.Parent.Spawn.MouseButton1Click:connect(function ()
  220.    
  221.     game.ReplicatedStorage.MorphEvent:FireServer(SelectedMorph)
  222.    
  223.     Camera.CameraType = "Custom"
  224.     script.Parent.Parent.Enabled = false
  225.    
  226.     Player.Character.Torso.CFrame = game.Workspace.FriendSpawn.CFrame  
  227.    
  228.     DevTrooper:Destroy()
  229.    
  230. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement