Advertisement
tubers93zxzxz

Fe LeaderStats

Feb 3rd, 2022
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 90.32 KB | None | 0 0
  1. game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
  2. local ADMINS =
  3. {
  4.     rbadam = 1,
  5.     adamintygum = 1,
  6.     androidtest = 1,
  7.     robloxfrenchie = 1,
  8.     jackssmirkingrevenge = 1,
  9.     mandaari = 1,
  10.     vaiobot = 1,
  11.     goddessnoob = 1,
  12.     thr33pakshak3r = 1,
  13.     effward = 1,
  14.     blockhaak = 1,
  15.     drewbda = 1,
  16.     triptych999 = 1,
  17.     tone = 1,
  18.     fasterbuilder19 = 1,
  19.     zeuxcg = 1,
  20.     concol2 = 1,
  21.     reesemcblox = 1,
  22.     jeditkacheff = 'http://www.roblox.com/asset/?id=134032333',
  23.     chiefjustus = 1,
  24.     ellissar = 1,
  25.     geekndestroy = 1,
  26.     noob007 = 1,
  27.     limon = 1,
  28.     hawkington = 1,
  29.     tabemono = 1,
  30.     autoconfig = 1,
  31.     brighteyes = 1,
  32.     monsterinc3d = 1,
  33.     isolatedevent = 1,
  34.     countonconnor = 1,
  35.     scubasomething = 1,
  36.     onlytwentycharacters = 1,
  37.     lordrugdumph = 1,
  38.     bellavour = 1,
  39.     ['david.baszucki'] = 1,
  40.     ibanez2189 = 1,
  41.     convexhero = 1,
  42.     sorcus = 'http://www.roblox.com/asset/?id=113059239',
  43.     deeana00 = 1,
  44.     thelorekt = 1,
  45.     ['mse6'] = 1,
  46.     corgiparade = 1,
  47.     varia = 1,
  48.     ['4runningwolves'] = 1,
  49.     pulmoesflor = 1,
  50.     olive71 = 1,
  51.     groundcontroll2 = 1,
  52.     gurukrish = 1,
  53.     countvelcro = 1,
  54.     iltalumi = 1,
  55.     juanjuan23 = 1,
  56.     ostrichsized = 1,
  57.     jackintheblox = 1,
  58.     slingshotjunkie = 1,
  59.     gordonrox24 = 1,
  60.     sharpnine = 1,
  61.     motornerve = 1,
  62.     watchmedogood = 1,
  63.     jmargh = 1,
  64.     jaykorean = 1,
  65.     foyle = 1,
  66.     majortom4321 = 1,
  67.     shedletsky = 'http://www.roblox.com/asset/?id=105897927',
  68.     supernovacaine = 1,
  69.     ffjosh = 1,
  70.     sickenedmonkey = 1,
  71.     doughtless = 1,
  72.     kbux = 1,
  73.     totallynothere = 1,
  74.     erzastar = 1,
  75.     keith = 1,
  76.     chro = 1,
  77.     solarcrane = 1,
  78.     glorioussalt = 1,
  79.     imightbelying = 1,
  80.     uristmcsparks = 1,
  81.     itolauren = 1,
  82.     malcomso = 1,
  83.     heyseptember = 1,
  84.     stickmasterluke = 1,
  85.     windlight13 = 1,
  86.     stravant = 1,
  87.     imaginationsensation = 1,
  88.     ['matt.dusek'] = 1,
  89.     crimmsonghost = 1,
  90.     mcrtest = 1,
  91.     maxvee = 1,
  92.     coatp0cketninja = 1,
  93.     screenme = 1,
  94.     b1tsh1ft = 1,
  95.     convexrumbler = 1,
  96.     mpliner476 = 1,
  97.     totbl = 1,
  98.     aquabot8 = 1,
  99.     grossinger = 1,
  100.     merely = 1,
  101.     cdakkar = 1,
  102.     siekiera = 1,
  103.     robloxkidsaccount = 1,
  104.     flotsamthespork = 1,
  105.     soggoth = 1,
  106.     phil = 1,
  107.     orcasparkles = 1,
  108.     skullgoblin = 1,
  109.     rickrosstheb0ss = 1,
  110.     argonpirate = 1,
  111.     nobledragon = 1,
  112.     squidcod = 1,
  113.     raeglyn = 1,
  114.     xerolayne = 1,
  115.     robloxsai = 'http://www.roblox.com/asset/?id=161078086',
  116.     briarroze = 1,
  117.     hawkeyebandit = 1,
  118.     dapperbuffalo = 1,
  119.     vukota = 1,
  120.     swiftstone = 1,
  121.     gemlocker = 1,
  122.     tarabyte = 1,
  123.     timobius = 1,
  124.     tobotrobot = 1,
  125.     foster008 = 1,
  126.     twberg = 1,
  127.     darthvaden = 1,
  128.     khanovich = 1,
  129.     codewriter = 1,
  130.     olefto = 1,
  131.     vladthefirst = 1,
  132.     phaedre = 1,
  133.     gorroth = 1,
  134.     jynj1984 = 1,
  135.     roboyz = 1,
  136.     zodiaczak = 1,
  137. }
  138.  
  139.  
  140. local Images = {
  141.     bottomDark = '94691904',
  142.     bottomLight = '94691940',
  143.     midDark = '94691980',
  144.     midLight = '94692025',
  145.     LargeDark = '96098866',
  146.     LargeLight = '96098920',
  147.     LargeHeader = '96097470',
  148.     NormalHeader = '94692054',
  149.     LargeBottom = '96397271',
  150.     NormalBottom = '94754966',
  151.     DarkBluePopupMid = '97114905',
  152.     LightBluePopupMid = '97114905',
  153.     DarkPopupMid = '97112126',
  154.     LightPopupMid = '97109338',
  155.     DarkBluePopupTop = '97114838',
  156.     DarkBluePopupBottom = '97114758',
  157.     DarkPopupBottom = '100869219',
  158.     LightPopupBottom = '97109175',
  159. }
  160.  
  161. local BASE_TWEEN = .25
  162.  
  163. local MOUSE_HOLD_TIME = .15
  164. local MOUSE_DRAG_DISTANCE = 15
  165.  
  166. local BACKGROUND_TRANSPARENCY = 0.7
  167. --[[
  168.     Generic object Create function, which I am using to create Gui's
  169.     Thanks to Stravant!
  170. --]]
  171. local Obj = {}
  172. function Obj.Create(guiType)
  173.     return function(data)
  174.         local obj = Instance.new(guiType)
  175.         for k, v in pairs(data) do
  176.             if type(k) == 'number' then
  177.                 v.Parent = obj
  178.             else
  179.                 obj[k] = v
  180.             end
  181.         end
  182.         return obj
  183.     end
  184. end
  185.  
  186. --[[
  187.     makes a full sized background for a guiobject
  188.     @Args:
  189.     imgName     asset name of image to fill background
  190.     @Return:    background gui object
  191. --]]
  192. function MakeBackgroundGuiObjOld(imgName)
  193.     return Obj.Create'ImageLabel'
  194.     {
  195.         Name = 'Background',
  196.         BackgroundTransparency = 1,
  197.         Image = imgName,
  198.         Position = UDim2.new(0, 0, 0, 0),
  199.         Size = UDim2.new(1,0,1,0),
  200.     }
  201. end
  202.  
  203. function MakeBackgroundGuiObj(imgName)
  204.     return Obj.Create'Frame'
  205.     {
  206.         Name = 'Background',
  207.         BackgroundTransparency = BACKGROUND_TRANSPARENCY,
  208.         BackgroundColor3 = Color3.new(0,0,0),
  209.         BorderSizePixel = 0,
  210.         Position = UDim2.new(0, 1, 0, 1),
  211.         Size = UDim2.new(1,-2,1,-2),
  212.     }
  213. end
  214.  
  215.  
  216. --[[ turns 255 integer color value to a color3 --]]
  217. function Color3I(r,g,b)
  218.     return Color3.new(r/255,g/255,b/255)
  219. end
  220.  
  221. --[[
  222.     Gets correct icon for builder's club status to display by name
  223.     @Args:
  224.     membershipType      Enum of membership status
  225.     @Return:            string of image asset
  226. --]]
  227. function getMembershipTypeIcon(membershipType,playerName)
  228.     if ADMINS[string.lower(playerName)]~=nil then
  229.         if ADMINS[string.lower(playerName)] == 1 then
  230.             return "http://www.roblox.com/asset/?id=99727663"
  231.         else
  232.             return ADMINS[string.lower(playerName)]
  233.         end
  234.     elseif membershipType == Enum.MembershipType.None then
  235.         return ""
  236.     elseif membershipType == Enum.MembershipType.BuildersClub then
  237.         return "rbxasset://textures/ui/TinyBcIcon.png"
  238.     elseif membershipType == Enum.MembershipType.TurboBuildersClub then
  239.         return "rbxasset://textures/ui/TinyTbcIcon.png"
  240.     elseif membershipType == Enum.MembershipType.OutrageousBuildersClub then
  241.         return "rbxasset://textures/ui/TinyObcIcon.png"
  242.     else
  243.         error("Unknown membershipType" .. membershipType)
  244.     end
  245. end
  246.  
  247. local function getFriendStatusIcon(friendStatus)
  248.     if friendStatus == Enum.FriendStatus.Unknown or friendStatus == Enum.FriendStatus.NotFriend then
  249.         return ""
  250.     elseif friendStatus == Enum.FriendStatus.Friend then
  251.         return "http://www.roblox.com/asset/?id=99749771"
  252.     elseif friendStatus == Enum.FriendStatus.FriendRequestSent then
  253.         return "http://www.roblox.com/asset/?id=99776888"
  254.     elseif friendStatus == Enum.FriendStatus.FriendRequestReceived then
  255.         return "http://www.roblox.com/asset/?id=99776838"
  256.     else
  257.         error("Unknown FriendStatus: " .. friendStatus)
  258.     end
  259. end
  260.  
  261.  
  262. --[[
  263.     Utility function to create buttons for the popup menus
  264.     @Args:
  265.     nparent     what to parent this button to
  266.     ntext       text to put on this button
  267.     index       number index of this entry in menu
  268.     last        is this the last element of the popup menu
  269.     @Return:    a popup menu button
  270. --]]
  271. function MakePopupButton(nparent,ntext,index,last)
  272.     local tobj = Obj.Create"ImageButton"
  273.     {
  274.         Name = 'ReportButton',
  275.         BackgroundTransparency = 1,
  276.         BackgroundColor3 = Color3.new(0, 0, 0),
  277.         Position = UDim2.new(0,0,1*index,0),
  278.         Size = UDim2.new(1, 0, 1, 0),
  279.         ZIndex=7,
  280.         Obj.Create'TextLabel'
  281.         {
  282.             Name = 'ButtonText',
  283.             BackgroundTransparency = 0.6,
  284.             BackgroundColor3 = Color3.new(0, 0, 0),
  285.             Position = UDim2.new(.07, 0, .07, 0),
  286.             Size = UDim2.new(.86,0,.86,0),
  287.             Parent = HeaderFrame,
  288.             Font = 'ArialBold',
  289.             Text = ntext,
  290.             FontSize = 'Size14',
  291.             TextScaled = true,
  292.             TextColor3 = Color3.new(1,1,1),
  293.             TextStrokeTransparency = 1,
  294.             ZIndex=7,
  295.         },
  296.         Parent = nparent,
  297.     }
  298.  
  299.     return tobj
  300. end
  301.  
  302.  
  303. --[[
  304.     obligatory wait for child function
  305.     @Args:
  306.     parent      Parent object to look for child in
  307.     child       name of child object to look for
  308.     @Return: object waited for
  309. --]]
  310. function WaitForChild(parent,child)
  311.     while not parent:FindFirstChild(child) do
  312.         wait() debugprint(" child "..parent.Name.." waiting for "..child)
  313.     end
  314.     return parent[child]
  315. end
  316.  
  317.  ---------------------------  
  318.  -- Workspace Objects
  319.  ---------------------------
  320.  
  321. -- might want to move all this to an init function, wait for localplayer elsewhere
  322. local Players = game:GetService('Players')
  323. -- make sure this doesn't run on the server(it will if you dont do this)
  324. while not Players.LocalPlayer do
  325.     Players.Changed:wait()
  326. end
  327.  
  328. local LocalPlayer = Players.LocalPlayer
  329. local Mouse = LocalPlayer:GetMouse()
  330.  
  331. local ScreenGui = Obj.Create"Frame"
  332. {
  333.     Name = 'PlayerListScreen',
  334.     Size = UDim2.new(1, 0, 1, 0),
  335.     BackgroundTransparency = 1,
  336.     Parent = script.Parent
  337. }
  338. local MainFrame = Obj.Create"Frame"
  339. {
  340.     Name = 'LeaderBoardFrame',
  341.     Position = UDim2.new(1, -150, 0.005, 0),
  342.     Size = UDim2.new(0, 150, 0, 800),
  343.     BackgroundTransparency = 1,
  344.     Parent = ScreenGui,
  345. }
  346.  
  347. --frame used for expanding leaderstats when frame is 'focused'
  348. local FocusFrame = Obj.Create"Frame"
  349. {
  350.     Name = 'FocusFrame',
  351.     Position = UDim2.new(0, 0, 0, 0),
  352.     Size = UDim2.new(1, 0, 0, 100),
  353.     BackgroundTransparency = 1,
  354.     Active = true,
  355.     Parent = MainFrame,
  356. }
  357.  
  358. local TemplateFrameYSize = 0.670000017
  359.  
  360. -- HEADER
  361. local HeaderFrame = Obj.Create"Frame"
  362. {
  363.     Name = 'Header',
  364.     BackgroundTransparency = 1,
  365.     Position = UDim2.new(0,0,0,0),
  366.     Size = UDim2.new(1, 0, .07, 0),
  367.     Parent = MainFrame,
  368.     MakeBackgroundGuiObj('http://www.roblox.com/asset/?id=94692054'),
  369. }
  370.     local HeaderFrameHeight = HeaderFrame.Size.Y.Scale
  371.     local MaximizeButton = Obj.Create"ImageButton"
  372.     {
  373.         Name = 'MaximizeButton',
  374.         Active = true,
  375.         BackgroundTransparency = 1,
  376.         Position = UDim2.new(0, 0, 0, 0),
  377.         Size = UDim2.new(1,0,1,0),
  378.         Parent = HeaderFrame,
  379.     }
  380.     local HeaderName = Obj.Create"TextLabel"
  381.     {
  382.         Name = 'PlayerName',
  383.         BackgroundTransparency = 1,
  384.         Position = UDim2.new(0, 0, .05, 0),
  385.         Size = UDim2.new(.98,0,.38,0),
  386.         Parent = HeaderFrame,
  387.         Font = 'ArialBold',
  388.         Text = LocalPlayer.Name,
  389.         FontSize='Size24',
  390.         --TextScaled = true,
  391.         TextColor3 = Color3.new(1,1,1),
  392.         TextStrokeColor3 = Color3.new(0,0,0),
  393.         TextStrokeTransparency = 0,
  394.         TextXAlignment = 'Right',
  395.         TextYAlignment = 'Center',
  396.     }
  397.     local HeaderScore = Obj.Create"TextLabel"
  398.     {
  399.         Name = 'PlayerScore',
  400.         BackgroundTransparency = 1,
  401.         Position = UDim2.new(0, 0, .4, 0),
  402.         Size = UDim2.new(.98,0,0,30),
  403.         Parent = HeaderFrame,
  404.         Font = 'ArialBold',
  405.         Text = '',
  406.         FontSize='Size24',
  407.         TextYAlignment = 'Top',
  408.         --TextScaled = true,
  409.         TextColor3 = Color3.new(1,1,1),
  410.         TextStrokeTransparency = 1,
  411.         TextXAlignment = 'Right',
  412.         TextYAlignment = 'Top',
  413.     }
  414.  -- BOTTOM
  415.  --used for shifting bottom frame for mouse over effects
  416. local BottomShiftFrame = Obj.Create"Frame"
  417. {
  418.     Name= 'BottomShiftFrame',
  419.     BackgroundTransparency = 1,
  420.     Position = UDim2.new(0,0,HeaderFrameHeight,0),
  421.     Size = UDim2.new(1,0,1,0),
  422.     Parent=MainFrame,
  423. }
  424.     local BottomFrame = Obj.Create"Frame"
  425.     {
  426.         Name = 'Bottom',
  427.         BackgroundTransparency = 1,
  428.         Position = UDim2.new(0,0,.07,0),
  429.         Size = UDim2.new(1, 0, .03, 0),
  430.         Parent = BottomShiftFrame,
  431.     }
  432.         local ExtendButton = Obj.Create"ImageButton"
  433.         {
  434.             Name = 'bigbutton',
  435.             Active = true,
  436.             BackgroundTransparency = 1,
  437.             Position = UDim2.new(0, 0, 0, 0),
  438.             Size = UDim2.new(1,0,1.5,0),
  439.             ZIndex = 3,
  440.             Parent = BottomFrame,
  441.         }
  442.         local ExtendTab = Obj.Create"ImageButton"
  443.         {
  444.             Name = 'extendTab',
  445.             Active = true,
  446.             BackgroundTransparency = 1,
  447.             Image = 'rbxasset://textures/ui/expandPlayerList.png',
  448.             Position = UDim2.new(.608, 0, .3, 0),
  449.             Size = UDim2.new(0,27,0,11),
  450.             Parent = BottomFrame,
  451.         }
  452. local TopClipFrame = Obj.Create"Frame"
  453. {
  454.     Name = 'ListFrame',
  455.     BackgroundTransparency = 1,
  456.     Position = UDim2.new(-1,0,.07,0),
  457.     Size = UDim2.new(2, 0, 1, 0),
  458.     Parent = MainFrame,
  459.     ClipsDescendants = true,
  460. }
  461.     local BottomClipFrame = Obj.Create"Frame"
  462.     {
  463.         Name = 'BottomFrame',
  464.         BackgroundTransparency = 1,
  465.         Position = UDim2.new(0,0, - .8,0),
  466.         Size = UDim2.new(1, 0, 1, 0),
  467.         Parent = TopClipFrame,
  468.         ClipsDescendants = true,
  469.     }
  470.         local ScrollBarFrame = Obj.Create"Frame"
  471.         {
  472.             Name = 'ScrollBarFrame',
  473.             BackgroundTransparency = 1,
  474.             Position = UDim2.new(.987,0,.8,0),
  475.             Size = UDim2.new(.01, 0, .2, 0),
  476.             Parent = BottomClipFrame,
  477.         }
  478.             local ScrollBar = Obj.Create"Frame"
  479.             {
  480.                 Name = 'ScrollBar',
  481.                 BackgroundTransparency = 0,
  482.                 BackgroundColor3 = Color3.new(.2,.2,.2),
  483.                 Position = UDim2.new(0,0,0,0),
  484.                 Size = UDim2.new(1, 0, .5, 0),
  485.                 ZIndex = 5,
  486.                 Parent = ScrollBarFrame,
  487.                
  488.             }
  489.         local ListFrame = Obj.Create"Frame"
  490.         {
  491.             Name = 'SubFrame',
  492.             BackgroundTransparency = 1,
  493.             Position = UDim2.new(0,0,.8,0),
  494.             Size = UDim2.new(1, 0, 1, 0),
  495.             Parent = BottomClipFrame,
  496.         }
  497. local PopUpClipFrame = Obj.Create"Frame"
  498. {
  499.     Name = 'PopUpFrame',
  500.     BackgroundTransparency = 1,
  501.     SizeConstraint='RelativeXX',
  502.     Position = MainFrame.Position + UDim2.new( 0,-150,0,0),
  503.     Size = UDim2.new(0,150,0,800),
  504.     Parent = MainFrame,
  505.     ClipsDescendants = true,
  506.     ZIndex=7,
  507. }
  508. local PopUpPanel = nil
  509.     local PopUpPanelTemplate = Obj.Create"Frame"
  510.     {
  511.         Name = 'Panel',
  512.         BackgroundTransparency = 1,
  513.         Position = UDim2.new(1,0,0,0),
  514.         Size = UDim2.new(1,0,.032,0),
  515.         Parent = PopUpClipFrame,
  516.     }
  517.        
  518. local StatTitles = Obj.Create"Frame"
  519. {
  520.     Name = 'StatTitles',
  521.     BackgroundTransparency = 1,
  522.     Position = UDim2.new(0,0,1,-10),
  523.     Size = UDim2.new(1, 0, 0, 0),
  524.     Parent = HeaderFrame,
  525. }
  526.  
  527. local IsMinimized = Instance.new('BoolValue')
  528. local IsMaximized = Instance.new('BoolValue')
  529. local IsTabified = Instance.new('BoolValue')
  530. local AreNamesExpanded = Instance.new('BoolValue')
  531.  
  532.  
  533. local MiddleTemplate = Obj.Create"Frame"
  534. {
  535.     Name = 'MidTemplate',
  536.     BackgroundTransparency = 1,
  537.     Position = UDim2.new(100,0,.07,0),
  538.     Size = UDim2.new(.5, 0, .025, 0),--UDim2.new(1, 0, .03, 0),
  539.     Obj.Create'ImageLabel'
  540.     {
  541.         Name = 'BCLabel',
  542.         Active = true,
  543.         BackgroundTransparency = 1,
  544.         Position = UDim2.new(.005, 5, .20, -2),
  545.         Size = UDim2.new(0,16,0,16),
  546.         SizeConstraint = 'RelativeYY',
  547.         Image = "",
  548.         ZIndex = 4,
  549.     },
  550.     Obj.Create'ImageLabel'
  551.     {
  552.         Name = 'FriendLabel',
  553.         Active = true,
  554.         BackgroundTransparency = 1,
  555.         Position = UDim2.new(.005, 5, .15, 0),
  556.         Size = UDim2.new(0,16,0,16),
  557.         SizeConstraint = 'RelativeYY',
  558.         Image = "",
  559.         ZIndex = 4,
  560.     },
  561.     Obj.Create"ImageButton"
  562.     {
  563.         Name = 'ClickListener',
  564.         Active = true,
  565.         BackgroundTransparency = 1,
  566.         BorderSizePixel = 0,
  567.         Position = UDim2.new(0, 1, 0, 1),
  568.         Size = UDim2.new(1, -2,1,-2),
  569.         ZIndex = 3,
  570.     },
  571.     Obj.Create"Frame"
  572.     {
  573.         Name = 'TitleFrame',
  574.         BackgroundTransparency = 1,
  575.         Position = UDim2.new(.01, 0, 0, 0),
  576.         Size = UDim2.new(0,140,1,0),
  577.         BorderSizePixel = 0,
  578.         ClipsDescendants=true,
  579.         Obj.Create"TextLabel"
  580.         {
  581.             Name = 'Title',
  582.             BackgroundTransparency = 1,
  583.             Position = UDim2.new(0, 5, 0, 0),
  584.             Size = UDim2.new(100,0,1,0),
  585.             Font = 'Arial',
  586.             FontSize='Size14',
  587.             TextColor3 = Color3.new(1,1,1),
  588.             TextXAlignment = 'Left',
  589.             TextYAlignment = 'Center',
  590.             ZIndex = 3,
  591.         },
  592.     },
  593.    
  594.     Obj.Create"TextLabel"
  595.     {
  596.         Name = 'PlayerScore',
  597.         BackgroundTransparency = 1,
  598.         Position = UDim2.new(0, 0, 0, 0),
  599.         Size = UDim2.new(1,0,1,0),
  600.         Font = 'ArialBold',
  601.         Text = '',
  602.         FontSize='Size14',
  603.         TextColor3 = Color3.new(1,1,1),
  604.         TextXAlignment = 'Right',
  605.         TextYAlignment = 'Center',
  606.         ZIndex = 3,
  607.     },
  608.     --Obj.Create'IntValue'{Name = 'ID'},
  609.     --Obj.Create'ObjectValue'{Name = 'Player'},
  610.     --Obj.Create'IntValue'{Name = 'Score'},
  611.     ZIndex = 3,
  612. }
  613. local MiddleBGTemplate = Obj.Create"Frame"
  614. {
  615.     Name = 'MidBGTemplate',
  616.     BackgroundTransparency = 1,
  617.     Position = UDim2.new(100,0,.07,0),
  618.     Size = UDim2.new(.5, 0, .025, 0),--UDim2.new(1, 0, .03, 0),
  619.     MakeBackgroundGuiObj('http://www.roblox.com/asset/?id=94692025'),
  620.    
  621. }
  622.  
  623.  -- REPORT ABUSE OBJECTS
  624.  
  625. local ReportAbuseShield = Obj.Create"TextButton"
  626. {
  627.     Name = "ReportAbuseShield",
  628.     Text = "",
  629.     AutoButtonColor = false,
  630.     Active = true,
  631.     Visible = true,
  632.     Size = UDim2.new(1,0,1,0),
  633.     BackgroundColor3 = Color3I(51,51,51),
  634.     BorderColor3 = Color3I(27,42,53),
  635.     BackgroundTransparency = 1,
  636. }
  637.  
  638. local ReportAbuseFrame = Obj.Create "Frame"
  639. {
  640.     Name = "Settings",
  641.     Position = UDim2.new(0.5, - 250, 0.5, - 200),
  642.     Size = UDim2.new(0.0, 500, 0.0, 400),
  643.     BackgroundTransparency = 1,
  644.     Active = true,
  645.     Parent = ReportAbuseShield,
  646. }
  647.  
  648. local AbuseSettingsFrame = Obj.Create"Frame"
  649. {
  650.     Name = "ReportAbuseStyle",
  651.     Size = UDim2.new(1, 0, 1, 0),
  652.     Active = true,
  653.     BackgroundTransparency = 1,
  654.     MakeBackgroundGuiObj('http://www.roblox.com/asset/?id=96488767'), -- 96480351'),
  655.     Obj.Create"TextLabel"
  656.     {
  657.         Name = "Title",
  658.         Text = "Report Abuse",
  659.         TextColor3 = Color3I(221,221,221),
  660.         Position = UDim2.new(0.5, 0, 0, 30),
  661.         Font = Enum.Font.ArialBold,
  662.         FontSize = Enum.FontSize.Size36,
  663.     },
  664.     Obj.Create"TextLabel"
  665.     {
  666.         Name = "Description",
  667.         Text = "This will send a complete report to a moderator.  The moderator will review the chat log and take appropriate action.",
  668.         TextColor3 = Color3I(221,221,221),
  669.         Position = UDim2.new(.01, 0, 0, 55),
  670.         Size = UDim2.new(.99, 0, 0, 40),
  671.         BackgroundTransparency = 1,
  672.         Font = Enum.Font.Arial,
  673.         FontSize = Enum.FontSize.Size18,
  674.         TextWrap = true,
  675.         TextXAlignment = Enum.TextXAlignment.Left,
  676.         TextYAlignment = Enum.TextYAlignment.Top,
  677.     },
  678.     Obj.Create"TextLabel"
  679.     {
  680.         Name = "AbuseLabel",
  681.         Text = "What did they do?",
  682.         Font = Enum.Font.Arial,
  683.         BackgroundTransparency = 1,
  684.         FontSize = Enum.FontSize.Size18,
  685.         Position = UDim2.new(0.025,0,0,140),
  686.         Size = UDim2.new(0.4,0,0,36),
  687.         TextColor3 = Color3I(255,255,255),
  688.         TextXAlignment = Enum.TextXAlignment.Left,
  689.     },
  690.     Obj.Create"TextLabel"
  691.     {
  692.         Name = "ShortDescriptionLabel",
  693.         Text = "Short Description: (optional)",
  694.         Font = Enum.Font.Arial,
  695.         FontSize = Enum.FontSize.Size18,
  696.         Position = UDim2.new(0.025,0,0,180),
  697.         Size = UDim2.new(0.95,0,0,36),
  698.         TextColor3 = Color3I(255,255,255),
  699.         TextXAlignment = Enum.TextXAlignment.Left,
  700.         BackgroundTransparency = 1,
  701.     },
  702.     Obj.Create"TextLabel"
  703.     {
  704.         Name = "ReportingPlayerLabel",
  705.         Text = "Reporting Player",
  706.         BackgroundTransparency = 1,
  707.         Font = Enum.Font.Arial,
  708.         FontSize = Enum.FontSize.Size18,
  709.         Position = UDim2.new(0.025,0,0,100),
  710.         Size = UDim2.new(0.95,0,0,36),
  711.         TextColor3 = Color3I(255,255,255),
  712.         TextXAlignment = Enum.TextXAlignment.Left,
  713.         Parent = AbuseSettingsFrame
  714.     },
  715.  
  716.     Parent = ReportAbuseFrame,
  717. }
  718.  
  719. local AbusePlayerLabel = Obj.Create"TextLabel"
  720. {
  721.     Name = "PlayerLabel",
  722.     Text = "",
  723.     BackgroundTransparency = 1,
  724.     Font = Enum.Font.ArialBold,
  725.     FontSize = Enum.FontSize.Size18,
  726.     Position = UDim2.new(0.025,0,0,100),
  727.     Size = UDim2.new(0.95,0,0,36),
  728.     TextColor3 = Color3I(255,255,255),
  729.     TextXAlignment = Enum.TextXAlignment.Right,
  730.     Parent = AbuseSettingsFrame
  731. }
  732.  
  733. local SubmitReportButton = Obj.Create"ImageButton"
  734. {
  735.     Name = "SubmitReportBtn",
  736.     Active = false,
  737.     BackgroundTransparency = 1,
  738.     Position = UDim2.new(.5, - 200, 1, - 80),
  739.     Size = UDim2.new(0,150,0,50),
  740.     AutoButtonColor = false,
  741.     Image = 'http://www.roblox.com/asset/?id=96502438', -- 96501119',
  742.     Parent = AbuseSettingsFrame,
  743. }
  744.  
  745. local CancelReportButton = Obj.Create"ImageButton"
  746. {
  747.     Name = "CancelBtn",
  748.     BackgroundTransparency = 1,
  749.     Position = UDim2.new(0.5, 50, 1, - 80),
  750.     Size = UDim2.new(0,150,0,50),
  751.     AutoButtonColor = true,
  752.     Image = 'http://www.roblox.com/asset/?id=96500683',
  753.     Parent = AbuseSettingsFrame,
  754. }
  755.  
  756. local AbuseDescriptionWrapper = Obj.Create"Frame"
  757. {
  758.     Name = "AbuseDescriptionWrapper",
  759.     Position = UDim2.new(0.025,0,0,220),
  760.     Size = UDim2.new(0.95,0,1, - 310),
  761.     BackgroundColor3 = Color3I(0,0,0),
  762.     BorderSizePixel = 0,
  763.     Parent = AbuseSettingsFrame,
  764. }
  765.  
  766. local AbuseDescriptionBox
  767.  
  768. local OriginalAbuseDescriptionBox = Obj.Create"TextBox"
  769. {
  770.     Name = "TextBox",
  771.     Text = "",
  772.     ClearTextOnFocus = false,
  773.     Font = Enum.Font.Arial,
  774.     FontSize = Enum.FontSize.Size18,
  775.     Position = UDim2.new(0,3,0,3),
  776.     Size = UDim2.new(1, - 6,1, - 6),
  777.     TextColor3 = Color3I(255,255,255),
  778.     TextXAlignment = Enum.TextXAlignment.Left,
  779.     TextYAlignment = Enum.TextYAlignment.Top,
  780.     TextWrap = true,
  781.     BackgroundColor3 = Color3I(0,0,0),
  782.     BorderSizePixel = 0,
  783. }
  784.  
  785. local CalmingAbuseBox = Obj.Create'Frame'
  786. {
  787.     Name = 'AbuseFeedbackBox',
  788.     BackgroundTransparency = 1,
  789.     Position=UDim2.new(0.25, 0, 0.300000012, 0),
  790.     Size=UDim2.new(0.5, 0, 0.370000005, 0),
  791.     MakeBackgroundGuiObj('http://www.roblox.com/asset/?id=96506233'),
  792.     Obj.Create'TextLabel'
  793.     {
  794.         Name = 'Header',
  795.         Position=UDim2.new(0,10,.05,0),
  796.         Size=UDim2.new(1, -30, .15, 0),
  797.         TextScaled = true,
  798.         BackgroundTransparency = 1,
  799.         TextXAlignment = Enum.TextXAlignment.Center,
  800.         TextYAlignment = Enum.TextYAlignment.Top,
  801.         Text = 'Thanks for your report!',
  802.         TextColor3 = Color3.new(1,1,1),
  803.         FontSize = Enum.FontSize.Size48,
  804.         Font = 'ArialBold',
  805.     },
  806.     Obj.Create'TextLabel'
  807.     {
  808.         Name = 'content',
  809.         Position = UDim2.new(0,10,.20,0),
  810.         Size = UDim2.new(1, -30, .40, 0),
  811.         TextScaled = true,
  812.         BackgroundTransparency = 1,
  813.         TextColor3 = Color3.new(1,1,1),
  814.         Text = 'Our moderators will review the chat logs and determine what happened.  The other user is probably just trying to make you mad.\n\nIf anyone used swear words, inappropriate language, or threatened you in real life, please report them for Bad Words or Threats',
  815.         TextWrapped = true,
  816.         TextYAlignment = Enum.TextYAlignment.Top,
  817.         FontSize = Enum.FontSize.Size24,
  818.         Font = 'Arial',
  819.     },
  820.     Obj.Create'ImageButton'
  821.     {
  822.         Name = "OkButton",
  823.         BackgroundTransparency = 1,
  824.         Position = UDim2.new(0.5, -75, 1, -80),
  825.         Size = UDim2.new(0,150,0,50),
  826.         AutoButtonColor = true,
  827.         Image = 'http://www.roblox.com/asset/?id=96507959',
  828.     }
  829. }
  830. local NormalAbuseBox = Obj.Create'Frame'
  831. {
  832.     Name = 'AbuseFeedbackBox',
  833.     BackgroundTransparency = 1,
  834.     Position = UDim2.new(0.25, 0, 0.300000012, 0),
  835.     Size = UDim2.new(0.5, 0, 0.370000005, 0),
  836.     MakeBackgroundGuiObj('http://www.roblox.com/asset/?id=96506233'),
  837.     Obj.Create'TextLabel'
  838.     {
  839.         Name = 'Header',
  840.         Position = UDim2.new(0,10,.05,0),
  841.         Size = UDim2.new(1, -30, .15, 0),
  842.         TextScaled = true,
  843.         BackgroundTransparency = 1,
  844.         TextColor3 = Color3.new(1,1,1),
  845.         TextXAlignment = Enum.TextXAlignment.Center,
  846.         TextYAlignment = Enum.TextYAlignment.Top,
  847.         Text = 'Thanks for your report!',
  848.         FontSize = Enum.FontSize.Size48,
  849.         Font ='ArialBold'
  850.     },
  851.     Obj.Create'TextLabel'
  852.     {
  853.         Name = 'content',
  854.         Position = UDim2.new(0,10,.20,0),
  855.         Size = UDim2.new(1, -30, .15, 0),
  856.         TextScaled = true,
  857.         BackgroundTransparency = 1,
  858.         TextColor3 = Color3.new(1,1,1),
  859.         Text = "Our moderators will review the chat logs and determine what happened.",
  860.         TextWrapped = true,
  861.         TextYAlignment = Enum.TextYAlignment.Top,
  862.         FontSize = Enum.FontSize.Size24,
  863.         Font = 'Arial',
  864.     },
  865.     Obj.Create'ImageButton'
  866.     {
  867.         Name = "OkButton",
  868.         BackgroundTransparency = 1,
  869.         Position = UDim2.new(0.5, -75, 1, -80),
  870.         Size = UDim2.new(0,150,0,50),
  871.         AutoButtonColor = true,
  872.         Image = 'http://www.roblox.com/asset/?id=96507959',
  873.     },
  874. }
  875.  
  876. local BigButton=Instance.new('ImageButton')
  877.     BigButton.Size=UDim2.new(1,0,1,0)
  878.     BigButton.BackgroundTransparency=1
  879.     BigButton.ZIndex=8
  880.     BigButton.Visible=false
  881.     --BigButton.Active=false
  882.     BigButton.Parent=ScreenGui
  883.    
  884.    
  885.  local debugFrame = Obj.Create"Frame"
  886.     {
  887.         Name = 'debugframe',
  888.         Position = UDim2.new(0, 0, 0, 0),
  889.         Size = UDim2.new(0, 150, 0, 800),--0.99000001
  890.         BackgroundTransparency = 1,
  891.        
  892.     }
  893.     local debugplayers = Obj.Create"TextLabel"
  894.     {
  895.         BackgroundTransparency = .8,
  896.         Position = UDim2.new(0, 0, .01, 0),
  897.         Size = UDim2.new(1,0,.5,0),
  898.         Parent = debugFrame,
  899.         Font = 'ArialBold',
  900.         Text = '--',
  901.         FontSize='Size14',
  902.         TextWrapped=true,
  903.         TextColor3 = Color3.new(1,1,1),
  904.         TextStrokeColor3 = Color3.new(0,0,0),
  905.         TextStrokeTransparency = 0,
  906.         TextXAlignment = 'Right',
  907.         TextYAlignment = 'Center',
  908.     }
  909.     local debugOutput = Obj.Create"TextLabel"
  910.     {
  911.         BackgroundTransparency = .8,
  912.         Position = UDim2.new(0, 0, .5, 0),
  913.         Size = UDim2.new(1,0,.5,0),
  914.         Parent = debugFrame,
  915.         Font = 'ArialBold',
  916.         Text = '--',
  917.         FontSize='Size14',
  918.         TextWrapped=true,
  919.         TextColor3 = Color3.new(1,1,1),
  920.         TextStrokeColor3 = Color3.new(0,0,0),
  921.         TextStrokeTransparency = 0,
  922.         TextXAlignment = 'Right',
  923.         TextYAlignment = 'Center',
  924.     }  
  925.  
  926.  
  927. --[[
  928.     simple function to toggle the display of debug output
  929. --]]
  930. local DebugPrintEnabled=true
  931. function debugprint(str)
  932.     --print(str)
  933.     if DebugPrintEnabled then
  934.         debugOutput.Text=str
  935.     end
  936. end
  937.  
  938.  
  939.  -------------------------  
  940.  -- Script objects
  941.  -------------------------
  942. local RbxGui = assert(LoadLibrary('RbxGui'))
  943.  
  944.  -- number of entries to show if you click minimize
  945. local DefaultEntriesOnScreen = 8
  946.  
  947.  
  948.    
  949.  
  950.  
  951. for _,i in pairs(Images) do
  952.     Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id="..i)
  953. end
  954.  
  955.  -- ordered array of 'score data', each entry has:
  956.  -- Name(String)
  957.  -- Priority(number)
  958.  -- IsPrimary (bool, should it be shown in upper right)
  959.  -- MaxLength (integer, of the length of the longest element for this column)
  960. local ScoreNames = {}
  961.  -- prevents flipping in playerlist panels
  962. local AddId = 0
  963.  -- intermediate table form of all player entries in format of:
  964.  -- Frame
  965.  -- Player
  966.  -- Score
  967.  -- ID
  968.  -- MyTeam (team ENRTY(not actual team) I am currently on)
  969. local PlayerFrames = {}
  970.  -- intermediate ordered frame array, composed of Entrys of
  971.  -- Frame
  972.  -- MyTeam (my team object)
  973.  -- MyPlayers ( an ordered array of all player frames in team )
  974.  -- AutoHide (bool saying whether it should be hidden)
  975.  -- IsHidden (bool)
  976.  -- ID (int to prevent flipping out of leaderboard, fun times)
  977. local TeamFrames = {}
  978.  -- one special entry from teamFrames, for unaffiliated players, only shown if players non - empty
  979. local NeutralTeam = nil
  980.  
  981.  -- final 'to be displayed' list of frames
  982. local MiddleFrames = {}
  983. local MiddleFrameBackgrounds = {}
  984. local MiddleFrameHeight = .03
  985.  -- time of last click
  986. local LastClick = 0
  987. local ButtonCooldown = .25
  988.  
  989. local OnIos = false
  990. pcall(function() OnIos = Game:GetService('UserInputService').TouchEnabled end)
  991.  
  992.  
  993.  -- you get 200 of x screen space per stat added, start width 16%
  994. local BaseScreenXSize = 150
  995. local SpacingPerStat = 10 --spacing between stats
  996.  
  997.  
  998. local MaximizedBounds = UDim2.new(.5,0,1,0)
  999. local MaximizedPosition = UDim2.new(.25,0,.1,0)
  1000. local NormalBounds = UDim2.new(0,BaseScreenXSize, 0, 800)
  1001. local NormalPosition = UDim2.new(1 , - BaseScreenXSize, 0.005, 0)
  1002.  
  1003. local MinimizedBounds = UDim2.new(0, BaseScreenXSize, 0.99000001, 0)
  1004.  
  1005. --free space to give last stat on the right
  1006. local RightEdgeSpace = -.04
  1007.  
  1008.  -- where the scroll par currently is positioned
  1009. local ScrollPosition = 0.75999999
  1010. local IsDragging = false -- am I dragging the player list
  1011.  
  1012. local DefaultBottomClipPos = BottomClipFrame.Position.Y.Scale
  1013.  
  1014. local LastSelectedPlayerEntry = nil
  1015. local SelectedPlayerEntry = nil
  1016. local SelectedPlayer = nil
  1017.  
  1018.  -- locks(semaphores) for stopping race conditions
  1019. local AddingFrameLock = false
  1020. local ChangingOrderLock = false
  1021. local AddingStatLock = false
  1022. local BaseUpdateLock = false
  1023. local WaitForClickLock = false
  1024. local InPopupWaitForClick=false
  1025. local PlayerChangedLock = false
  1026. local NeutralTeamLock = false
  1027.  
  1028. local ScrollWheelConnections = {}
  1029.  
  1030.  
  1031. local DefaultListSize = 15
  1032. if not OnIos then DefaultListSize = 24 end
  1033. local DidMinimizeDrag = false
  1034.  
  1035. --local PlaceCreatorId=game.CreatorId
  1036.  
  1037.  -- report abuse objects
  1038. local AbuseName
  1039. local Abuses = {
  1040.     "Bad Words or Threats",
  1041.     "Bad Username",
  1042.     "Talking about Dating",
  1043.     "Account Trading or Sharing",
  1044.     "Asking Personal Questions",
  1045.     "Rude or Mean Behavior",
  1046.     "False Reporting Me"
  1047. }
  1048. local UpdateAbuseFunction
  1049. local AbuseDropDown, UpdateAbuseSelection
  1050.  
  1051. local PrivilegeLevel =
  1052. {
  1053.     Owner = 255,
  1054.     Admin = 240,
  1055.     Member = 128,
  1056.     Visitor = 10,
  1057.     Banned = 0,
  1058. }
  1059.  
  1060.  
  1061. local IsPersonalServer = (game:GetService("Workspace"):FindFirstChild("PSVariable") ~= nil)
  1062.  
  1063. game:GetService("Workspace").ChildAdded:connect(function(nchild)
  1064.     if nchild.Name=='PSVariable' and nchild:IsA('BoolValue') then
  1065.         IsPersonalServer=true
  1066.     end
  1067. end)
  1068.  -------------------------------  
  1069.  -- Static Functions
  1070.  -------------------------------
  1071. function GetTotalEntries()
  1072.     return math.min(#MiddleFrameBackgrounds,DefaultEntriesOnScreen)
  1073. end
  1074.  
  1075. function GetEntryListLength()
  1076.     local numEnts=#PlayerFrames+#TeamFrames
  1077.     if NeutralTeam then
  1078.         numEnts=numEnts+1
  1079.     end
  1080.     return numEnts
  1081. end
  1082.  
  1083. function AreAllEntriesOnScreen()
  1084.     return #MiddleFrameBackgrounds * MiddleTemplate.Size.Y.Scale <= 1 + DefaultBottomClipPos
  1085. end
  1086.  
  1087. function GetLengthOfVisbleScroll()
  1088.     return 1 + DefaultBottomClipPos
  1089. end
  1090.  
  1091. function GetMaxScroll()
  1092.     return DefaultBottomClipPos *  - 1
  1093. end
  1094.  -- can be optimized by caching when this varible changes
  1095. function GetMinScroll()
  1096.     if AreAllEntriesOnScreen() then
  1097.         return GetMaxScroll()
  1098.     else
  1099.         return (GetMaxScroll() - (#MiddleFrameBackgrounds * MiddleTemplate.Size.Y.Scale)) + (1 + DefaultBottomClipPos)
  1100.     end
  1101. end
  1102.  
  1103. function AbsoluteToPercent(x,y)
  1104.     return Vector2.new(x,y)/ScreenGui.AbsoluteSize
  1105. end
  1106. --[[
  1107.     tweens property of element from starta to enda over length of time
  1108.     Warning: should be put in a Spawn call
  1109.     @Args:
  1110.     element     textobject to tween transparency on
  1111.     propName
  1112.     starta      alpha to start tweening
  1113.     enda        alpha to end tweening on
  1114.     length      how many seconds to spend tweening
  1115. --]]
  1116. function TweenProperty(obj, propName, inita, enda, length)
  1117.     local startTime = tick()
  1118.     while tick()-startTime<length do
  1119.         obj[propName] = ((enda-inita)*((tick()-startTime)/length))+inita
  1120.         wait(1/30)
  1121.     end
  1122.     obj[propName] = enda   
  1123. end
  1124. --[[
  1125.     UGLY UGLY HACK FUNCTION
  1126.     replace with some sort of global input catching A.S.A. FREAKING P.
  1127.     creates a fullsize gui element to catch next mouse up event(completeing a click)
  1128.     @Args:
  1129.     frameParent     Object to parent fullscreen gui to
  1130.     polledFunction  function to call on mouse moved events in this gui
  1131.     exitFunction    function to call when click event is fired
  1132. --]]
  1133.  
  1134. function WaitForClick(frameParent,polledFunction,exitFunction)
  1135.    
  1136.     if WaitForClickLock then return end
  1137.     WaitForClickLock=true
  1138.     local upHappened=false
  1139.     local connection, connection2
  1140.     connection=BigButton.MouseButton1Up:connect(function(nx,ny)
  1141.         exitFunction(nx,ny)
  1142.         BigButton.Visible=false
  1143.         connection:disconnect()
  1144.         if connection2 then
  1145.             connection2:disconnect()
  1146.         end
  1147.         --debugprint('mouse up!')
  1148.     end)
  1149.     connection2=BigButton.MouseMoved:connect( function(nx,ny)
  1150.         polledFunction(nx,ny)
  1151.        
  1152.     end)
  1153.    
  1154.     --debugprint('waiting for click!')
  1155.     BigButton.Visible=true
  1156.     BigButton.Active=true
  1157.     BigButton.Parent=frameParent
  1158.     frameParent.AncestryChanged:connect(function(child,nparent)
  1159.         if child == frameParent and nparent ==nil then
  1160.             exitFunction(nx,ny)
  1161.             BigButton.Visible=false
  1162.             connection:disconnect()
  1163.             connection2:disconnect()
  1164.             debugprint("forced out of wait for click")
  1165.         end
  1166.     end)
  1167.     WaitForClickLock=false
  1168. end
  1169.  
  1170.  
  1171.  
  1172. ---------------------------
  1173. --Personal Server Handling
  1174. ---------------------------
  1175. --[[
  1176.     returns privlage level based on integer rank
  1177.     Note: these privilege levels seem completely arbitrary, but no documentation exists
  1178.     this is all from the old player list, really weird
  1179.     @Args:
  1180.     rank    Integer rank value for player
  1181.     @Return     Normalized integer value for rank?
  1182. --]]
  1183. function GetPrivilegeType(rank)
  1184.     if rank <= PrivilegeLevel['Banned'] then
  1185.         return PrivilegeLevel['Banned']
  1186.     elseif rank <= PrivilegeLevel['Visitor'] then
  1187.         return PrivilegeLevel['Visitor']
  1188.     elseif rank <= PrivilegeLevel['Member'] then
  1189.         return PrivilegeLevel['Member']
  1190.     elseif rank <= PrivilegeLevel['Admin'] then
  1191.         return PrivilegeLevel['Admin']
  1192.     else
  1193.         return PrivilegeLevel['Owner']
  1194.     end
  1195. end
  1196.  
  1197. --[[
  1198.     gives a player a new privilage rank
  1199.     Note: Very odd that I have to use loops with this instead of directly setting the rank
  1200.     but no documentation for personal server service exists
  1201.     @Args:
  1202.     player      player to change rank of
  1203.     nrank       new integer rank to give player
  1204. --]]
  1205. function SetPrivilegeRank(player,nrank)
  1206.     while player.PersonalServerRank<nrank do
  1207.         game:GetService("PersonalServerService"):Promote(player)
  1208.     end
  1209.     while player.PersonalServerRank>nrank do
  1210.         game:GetService("PersonalServerService"):Demote(player)
  1211.     end
  1212. end
  1213. --[[
  1214.     called when player selects new privilege level from popup menu
  1215.     @Args:
  1216.     player      player to set privileges on
  1217.     nlevel      new privilege level for this player
  1218. --]]
  1219. function OnPrivilegeLevelSelect(player,nlevel,BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  1220.     debugprint('setting privilege level')
  1221.     SetPrivilegeRank(player,nlevel)
  1222.     HighlightMyRank(player,BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  1223. end
  1224.  
  1225. --[[
  1226.     Highlights current rank of this player in the popup menu
  1227.     @Args:
  1228.     player      Player to check for rank on
  1229. --]]
  1230. function HighlightMyRank(player,BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  1231.     BanPlayerButton.Image= 'http://www.roblox.com/asset/?id='..Images['LightPopupMid']
  1232.     VisitorButton.Image= 'http://www.roblox.com/asset/?id='..Images['DarkPopupMid']
  1233.     MemberButton.Image= 'http://www.roblox.com/asset/?id='..Images['LightPopupMid']
  1234.     AdminButton.Image= 'http://www.roblox.com/asset/?id='..Images['DarkPopupBottom']
  1235.    
  1236.     local rank=player.PersonalServerRank
  1237.     if rank <= PrivilegeLevel['Banned'] then
  1238.         BanPlayerButton.Image='http://www.roblox.com/asset/?id='..Images['LightBluePopupMid']
  1239.     elseif rank <= PrivilegeLevel['Visitor'] then
  1240.         VisitorButton.Image='http://www.roblox.com/asset/?id='..Images['DarkBluePopupMid']
  1241.     elseif rank <= PrivilegeLevel['Member'] then
  1242.         MemberButton.Image='http://www.roblox.com/asset/?id='..Images['LightBluePopupMid']
  1243.     elseif rank <= PrivilegeLevel['Admin'] then
  1244.         AdminButton.Image= 'http://www.roblox.com/asset/?id='..Images['DarkBluePopupBottom']
  1245.     end
  1246. end
  1247.  
  1248.  --------------------------  
  1249.  -- Report abuse handling
  1250.  --------------------------
  1251. --[[
  1252.     does final reporting of abuse on selected player, calls closeAbuseDialog
  1253. --]]
  1254. function OnSubmitAbuse()
  1255.     if SubmitReportButton.Active then
  1256.         if AbuseName and SelectedPlayer then
  1257.             AbuseSettingsFrame.Visible = false
  1258.             game:GetService("Players"):ReportAbuse(SelectedPlayer, AbuseName, AbuseDescriptionBox.Text)
  1259.             if AbuseName == "Rude or Mean Behavior" or AbuseName == "False Reporting Me" then
  1260.                 CalmingAbuseBox.Parent = ReportAbuseShield
  1261.             else
  1262.                 debugprint('opening abuse box')
  1263.                 NormalAbuseBox.Parent = ReportAbuseShield
  1264.             end
  1265.         else
  1266.             CloseAbuseDialog()
  1267.         end
  1268.     end
  1269. end
  1270.  
  1271. --[[
  1272.     opens the abuse dialog, initialises text to display selectedplayer
  1273. --]]
  1274. function OpenAbuseDialog()
  1275.     debugprint('adding report dialog')
  1276.     AbusePlayerLabel.Text = SelectedPlayer.Name
  1277.     --AbuseDescriptionBox.Text = ""
  1278.     PopUpPanel:TweenPosition(UDim2.new(1,0,0,0), "Out", "Linear", BASE_TWEEN,true)
  1279.     AbuseDescriptionBox=OriginalAbuseDescriptionBox:Clone()
  1280.     AbuseDescriptionBox.Parent = AbuseDescriptionWrapper
  1281.     ReportAbuseShield.Parent = ScreenGui
  1282.     ClosePopUpPanel()
  1283. end
  1284. --[[
  1285.     resets and closes abuse dialog
  1286. --]]
  1287. function CloseAbuseDialog()
  1288.     AbuseName = nil
  1289.     SubmitReportButton.Active = false
  1290.     SubmitReportButton.Image = 'http://www.roblox.com/asset/?id=96502438' -- 96501119',
  1291.     AbuseDescriptionBox:Destroy()
  1292.     CalmingAbuseBox.Parent = nil
  1293.     NormalAbuseBox.Parent = nil
  1294.     ReportAbuseShield.Parent = nil
  1295.     AbuseSettingsFrame.Visible = true
  1296. end
  1297.  
  1298. --[[
  1299.     creates dropdownbox, registers all listeners for abuse dialog
  1300. --]]
  1301. function InitReportAbuse()
  1302.  
  1303.     UpdateAbuseFunction = function(abuseText)
  1304.         AbuseName = abuseText
  1305.         if AbuseName and SelectedPlayer then
  1306.             SubmitReportButton.Active = true
  1307.             SubmitReportButton.Image = 'http://www.roblox.com/asset/?id=96501119'
  1308.         end
  1309.     end
  1310.    
  1311.     AbuseDropDown, UpdateAbuseSelection = RbxGui.CreateDropDownMenu(Abuses, UpdateAbuseFunction, true)
  1312.     AbuseDropDown.Name = "AbuseComboBox"
  1313.     AbuseDropDown.Position = UDim2.new(0.425, 0, 0, 142)
  1314.     AbuseDropDown.Size = UDim2.new(0.55,0,0,32)
  1315.     AbuseDropDown.Parent = AbuseSettingsFrame
  1316.    
  1317.    
  1318.     CancelReportButton.MouseButton1Click:connect(CloseAbuseDialog)
  1319.     SubmitReportButton.MouseButton1Click:connect(OnSubmitAbuse)
  1320.    
  1321.     CalmingAbuseBox:FindFirstChild('OkButton').MouseButton1Down:connect(CloseAbuseDialog)
  1322.     NormalAbuseBox:FindFirstChild('OkButton').MouseButton1Down:connect(CloseAbuseDialog)
  1323. end
  1324.  
  1325. -------------------------------------
  1326. -- Friend/unfriending
  1327. -------------------------------------
  1328. --[[
  1329.     gets enum val of friend status, uses pcall for some reason?(from old playerlist)
  1330.     @Args:
  1331.     player  player object to check if friends with
  1332.     @Return: enum of friend status
  1333. --]]
  1334. local function GetFriendStatus(player)
  1335.     if player == game:GetService("Players").LocalPlayer then
  1336.         return Enum.FriendStatus.NotFriend
  1337.     else
  1338.         local success, result = pcall(function() return game:GetService("Players").LocalPlayer:GetFriendStatus(player) end)
  1339.         if success then
  1340.             return result
  1341.         else
  1342.             return Enum.FriendStatus.NotFriend
  1343.         end
  1344.     end
  1345. end
  1346.  
  1347. --[[
  1348.     when friend button is clicked, tries to take appropriate action,
  1349.     based on current friend status with SelectedPlayer
  1350. --]]
  1351. function OnFriendButtonSelect()
  1352.    
  1353.     local friendStatus=GetFriendStatus(SelectedPlayer)
  1354.     if friendStatus==Enum.FriendStatus.Friend then
  1355.         LocalPlayer:RevokeFriendship(SelectedPlayer)
  1356.     elseif friendStatus==Enum.FriendStatus.Unknown or friendStatus==Enum.FriendStatus.NotFriend then
  1357.         LocalPlayer:RequestFriendship(SelectedPlayer)
  1358.     elseif friendStatus==Enum.FriendStatus.FriendRequestSent then
  1359.         LocalPlayer:RevokeFriendship(SelectedPlayer)
  1360.     elseif  friendStatus==Enum.FriendStatus.FriendRequestReceived then
  1361.         LocalPlayer:RequestFriendship(SelectedPlayer)
  1362.     end
  1363.     --PersonalServerPanel:TweenPosition(UDim2.new(1,0,0,0), "Out", "Quad", .5,true)
  1364.     ClosePopUpPanel()
  1365.     --PopUpPanel:TweenPosition(UDim2.new(1,0,0,0), "Out", "Linear", BASE_TWEEN,true)
  1366. end
  1367.  
  1368. function OnFriendRefuseButtonSelect()
  1369.    
  1370.  
  1371.     LocalPlayer:RevokeFriendship(SelectedPlayer)
  1372.     ClosePopUpPanel()
  1373.     PopUpPanel:TweenPosition(UDim2.new(1,0,0,0), "Out", "Linear", BASE_TWEEN,true)
  1374. end
  1375. ------------------------------------  
  1376. -- Player Entry Handling
  1377. ------------------------------------
  1378. --[[
  1379.     used by lua's table.sort to sort player entries
  1380. --]]
  1381. function PlayerSortFunction(a,b)
  1382. -- prevents flipping out leaderboard
  1383.     if a['Score'] == b['Score'] then
  1384.         return a['Player'].Name:upper() > b['Player'].Name:upper()
  1385.     end
  1386.     if not a['Score'] then return false end
  1387.     if not b['Score'] then return true end
  1388.     return a['Score'] < b['Score']
  1389. end
  1390.  
  1391. ---------------------------------  
  1392. -- Stat Handling
  1393. ---------------------------------  
  1394. -- removes and closes all leaderboard stuffs
  1395. function BlowThisPopsicleStand()
  1396.     --ScreenGui:Destroy()
  1397.     --script:Destroy()
  1398.     --time to make the fanboys rage...
  1399.     Tabify()
  1400. end
  1401. --[[
  1402.     used by lua's table.sort to prioritize score entries
  1403. --]]
  1404. function StatSort(a,b)
  1405.  -- primary stats should be shown before all others
  1406.     if a.IsPrimary ~= b.IsPrimary then
  1407.         return a.IsPrimary
  1408.     end
  1409.  -- if priorities are equal, then return the first added one
  1410.     if a.Priority == b.Priority then
  1411.         return a.AddId < b.AddId
  1412.     end
  1413.     return a.Priority < b.Priority
  1414. end
  1415. --[[
  1416.     doing WAAY too much here, for optimization update only your team
  1417.     @Args:
  1418.     playerEntry     Entry of player who had a stat change
  1419.     property        Name of stat changed
  1420. --]]
  1421. function StatChanged(playerEntry,property)
  1422.  
  1423.  -- if(playerEntry['MyTeam']) then
  1424.  -- UpdateSingleTeam(playerEntry['MyTeam'])
  1425.  -- else
  1426.         BaseUpdate()
  1427.  -- end
  1428. end
  1429. --[[
  1430.     Called when stat is added
  1431.     if playerEntry is localplayer, will add to score names and re-sort the stats, and resize the width of the leaderboard
  1432.     for all players, will add a listener for if this stat changes
  1433.     if stat is a string value, crashes the leaderboard
  1434.     Note:change crash to a 'tabify' leaderboard later
  1435.     @Args:
  1436.     nchild          new child value to leaderstats
  1437.     playerEntry     entry this stat was added to
  1438. --]]
  1439. function StatAdded(nchild,playerEntry)
  1440.  -- dont re - add a leaderstat I alreday have
  1441.     while AddingStatLock do debugprint('in stat added function lock') wait(1/30) end
  1442.     AddingStatLock = true
  1443.     if not (nchild:IsA('StringValue') or nchild:IsA('IntValue') or nchild:IsA('BoolValue') or nchild:IsA('NumberValue') or nchild:IsA('DoubleConstrainedValue') or nchild:IsA('IntConstrainedValue')) then
  1444.         BlowThisPopsicleStand()
  1445.     else
  1446.         local haveScore = false
  1447.         for _,i in pairs(ScoreNames) do
  1448.             if i['Name']==nchild.Name then haveScore=true end
  1449.         end
  1450.         if not haveScore then
  1451.             local nstat = {}
  1452.             nstat['Name'] = nchild.Name
  1453.             nstat['Priority'] = 0
  1454.             if(nchild:FindFirstChild('Priority')) then
  1455.                 nstat['Priority'] = nchild.Priority
  1456.             end
  1457.             nstat['IsPrimary'] = false
  1458.             if(nchild:FindFirstChild('IsPrimary')) then
  1459.                 nstat['IsPrimary'] = true
  1460.             end
  1461.             nstat.AddId = AddId
  1462.             AddId = AddId + 1
  1463.             table.insert(ScoreNames,nstat)
  1464.             table.sort(ScoreNames,StatSort)
  1465.             if not StatTitles:FindFirstChild(nstat['Name']) then
  1466.                 CreateStatTitle(nstat['Name'])
  1467.             end
  1468.             UpdateMaximize()
  1469.  
  1470.         end
  1471.     end
  1472.         AddingStatLock = false
  1473.         StatChanged(playerEntry)
  1474.         nchild.Changed:connect(function(property) StatChanged(playerEntry,property) end)
  1475.    
  1476.    
  1477. end
  1478. --returns whether any of the existing players has this stat
  1479. function DoesStatExist(statName, exception)
  1480.     for _,playerf in pairs(PlayerFrames) do
  1481.         if playerf['Player'] ~= exception and playerf['Player']:FindFirstChild('leaderstats') and playerf['Player'].leaderstats:FindFirstChild(statName) then
  1482.             --print('player:' .. playerf['Player'].Name ..' has stat')
  1483.             return true
  1484.         end
  1485.     end
  1486.     return false
  1487. end
  1488.  
  1489.  
  1490.  
  1491. --[[
  1492.     Called when stat is removed from player
  1493.     for all players, destroys the stat frame associated with this value,
  1494.     then calls statchanged(to resize frame)
  1495.     if playerEntry==localplayer, will remove from scorenames
  1496.     @Args:
  1497.     nchild          ___value to be removed
  1498.     playerEntry     entry of player value is being removed from
  1499. --]]
  1500. function StatRemoved(nchild,playerEntry)
  1501.     while AddingStatLock do debugprint('In Adding Stat Lock1') wait(1/30) end
  1502.     AddingStatLock = true
  1503.     if playerEntry['Frame']:FindFirstChild(nchild.Name) then
  1504.         debugprint('Destroyed frame!')
  1505.         playerEntry['Frame'][nchild.Name].Parent = nil
  1506.     end
  1507.     if not DoesStatExist(nchild.Name, playerEntry['Player']) then
  1508.         for i,val in ipairs(ScoreNames) do
  1509.             if val['Name'] == nchild.Name then
  1510.                 table.remove(ScoreNames,i)
  1511.                 if StatTitles:FindFirstChild(nchild.Name) then
  1512.                     StatTitles[nchild.Name]:Destroy()
  1513.                 end
  1514.                 for _,teamf in pairs(TeamFrames) do
  1515.                     if teamf['Frame']:FindFirstChild(nchild.Name) then
  1516.                         teamf['Frame'][nchild.Name]:Destroy()
  1517.                     end
  1518.                 end
  1519.             end
  1520.         end
  1521.     end
  1522.     AddingStatLock = false
  1523.     StatChanged(playerEntry)
  1524. end
  1525. --[[
  1526.     clears all stats from a given playerEntry
  1527.     resets the HeadScore's Text property to an empty string
  1528.     used when leaderstats are removed, or when new leaderstats are added(for weird edge case)+
  1529. --]]
  1530. function RemoveAllStats(playerEntry)
  1531.     for i,val in ipairs(ScoreNames) do
  1532.         StatRemoved(val,playerEntry)
  1533.     end HeaderScore.Text = ''
  1534.    
  1535. end
  1536.  
  1537.  
  1538. function GetScoreValue(score)
  1539.     if score:IsA('DoubleConstrainedValue') or score:IsA('IntConstrainedValue') then
  1540.         return score.ConstrainedValue
  1541.     elseif score:IsA('BoolValue') then
  1542.         if score.Value then return 1 else return 0 end
  1543.     else
  1544.         return score.Value
  1545.     end
  1546. end
  1547. --[[
  1548.    
  1549. --]]
  1550. function MakeScoreEntry(entry,scoreval,panel)
  1551.     if not panel:FindFirstChild('PlayerScore') then return end
  1552.     local nscoretxt = panel:FindFirstChild('PlayerScore'):Clone()
  1553.     local thisScore = nil
  1554.     --here lies the resting place of a once great and terrible bug
  1555.     --may its treachery never be forgoten, lest its survivors fall for it again
  1556.     --RIP the leaderstat bug, oct 2012-nov 2012
  1557.     wait()
  1558.     if entry['Player']:FindFirstChild('leaderstats') and entry['Player'].leaderstats:FindFirstChild(scoreval['Name']) then
  1559.         thisScore = entry['Player']:FindFirstChild('leaderstats'):FindFirstChild(scoreval['Name'])
  1560.     else
  1561.         return
  1562.     end
  1563.    
  1564.     if not entry['Player'].Parent then return end
  1565.    
  1566.     nscoretxt.Name = scoreval['Name']
  1567.     nscoretxt.Text = tostring(GetScoreValue(thisScore))
  1568.     if scoreval['Name'] == ScoreNames[1]['Name'] then
  1569.         debugprint('changing score')
  1570.         entry['Score'] = GetScoreValue(thisScore)
  1571.         if entry['Player'] == LocalPlayer then HeaderScore.Text = tostring(GetScoreValue(thisScore)) end
  1572.     end
  1573.  
  1574.     thisScore.Changed:connect(function()
  1575.         if not thisScore.Parent then return end
  1576.         if scoreval['Name'] == ScoreNames[1]['Name'] then
  1577.            
  1578.             entry['Score'] = GetScoreValue(thisScore)
  1579.             if entry['Player'] == LocalPlayer then HeaderScore.Text = tostring(GetScoreValue(thisScore)) end
  1580.         end
  1581.         nscoretxt.Text = tostring(GetScoreValue(thisScore))
  1582.         BaseUpdate()
  1583.     end)
  1584.     return nscoretxt
  1585.  
  1586. end
  1587.  
  1588. function CreateStatTitle(statName)
  1589.    
  1590.     local ntitle = MiddleTemplate:FindFirstChild('PlayerScore'):Clone()
  1591.     ntitle.Name = statName
  1592.     ntitle.Text = statName
  1593.     -- ntitle
  1594.     if IsMaximized.Value then
  1595.         ntitle.TextTransparency = 0
  1596.     else
  1597.         ntitle.TextTransparency = 1
  1598.     end
  1599.     ntitle.Parent = StatTitles
  1600. end
  1601.  
  1602. function RecreateScoreColumns(ptable)
  1603.     while AddingStatLock do debugprint ('In Adding Stat Lock2') wait(1/30) end
  1604.     AddingStatLock = true
  1605.     local Xoffset=5--15 --current offset from Right
  1606.     local maxXOffset=Xoffset
  1607.     local MaxSizeColumn=0 --max size for this column
  1608.    
  1609.     -- foreach known leaderstat
  1610.     for j = #ScoreNames, 1,-1 do
  1611.         local scoreval = ScoreNames[j]
  1612.  
  1613.         MaxSizeColumn=0
  1614.         -- for each entry in this player table
  1615.         for i,entry in ipairs(ptable) do
  1616.             local panel = entry['Frame']
  1617.             local tplayer = entry['Player']
  1618.             -- if this panel does not have an element named after this stat
  1619.             if not panel:FindFirstChild(scoreval['Name']) then
  1620.                 -- make an entry for this object
  1621.                 local nentry = MakeScoreEntry(entry,scoreval,panel)
  1622.                 if nentry then
  1623.                     debugprint('adding '..nentry.Name..' to '..entry['Player'].Name )
  1624.                     nentry.Parent = panel
  1625.                     -- add score to team
  1626.                     if entry['MyTeam'] and entry['MyTeam'] ~= NeutralTeam and not entry['MyTeam']['Frame']:FindFirstChild(scoreval['Name']) then
  1627.                         local ntitle = nentry:Clone()
  1628.                         --ntitle.TextXAlignment  = 'Right'
  1629.                         ntitle.Parent = entry['MyTeam']['Frame']
  1630.                     end
  1631.                    
  1632.                 end
  1633.             end
  1634.             scoreval['XOffset']=Xoffset
  1635.  
  1636.             if panel:FindFirstChild(scoreval['Name']) then
  1637.                 MaxSizeColumn=math.max(MaxSizeColumn,panel[scoreval['Name']].TextBounds.X)
  1638.             end
  1639.         end
  1640.  
  1641.         if AreNamesExpanded.Value then
  1642.             MaxSizeColumn=math.max(MaxSizeColumn,StatTitles[scoreval['Name'] ].TextBounds.X)
  1643.             StatTitles[scoreval['Name'] ]:TweenPosition(UDim2.new(RightEdgeSpace,-Xoffset,0,0),'Out','Linear',BASE_TWEEN,true)
  1644.         else
  1645.             StatTitles[scoreval['Name'] ]:TweenPosition(UDim2.new((.4+((.6/#ScoreNames)*(j-1)))-1,0,0,0),'Out','Linear',BASE_TWEEN,true)
  1646.         end
  1647.         scoreval['ColumnSize']=MaxSizeColumn
  1648.         Xoffset= Xoffset+SpacingPerStat+MaxSizeColumn
  1649.         maxXOffset=math.max(Xoffset,maxXOffset)
  1650.     end
  1651.     NormalBounds = UDim2.new(0, BaseScreenXSize+maxXOffset-SpacingPerStat,0,800)
  1652.     NormalPosition = UDim2.new(1 , -NormalBounds.X.Offset, NormalPosition.Y.Scale, 0)
  1653.     UpdateHeaderNameSize()
  1654.     UpdateMaximize()
  1655.    
  1656.     AddingStatLock = false
  1657. end
  1658. ---------------------------  
  1659. -- Minimizing and maximizing
  1660. ---------------------------
  1661.  
  1662. function ToggleMinimize()
  1663.     IsMinimized.Value = not IsMinimized.Value
  1664.     UpdateStatNames()
  1665. end
  1666.  
  1667. function ToggleMaximize()
  1668.     IsMaximized.Value = not IsMaximized.Value
  1669.     RecreateScoreColumns(PlayerFrames) --done to re-position stat names NOTE: optimize-able
  1670. end
  1671.  
  1672. function Tabify()
  1673.     IsTabified.Value= true
  1674.     IsMaximized.Value=false
  1675.     IsMinimized.Value=true
  1676.     UpdateMinimize()
  1677.     IsTabified.Value= true
  1678.     ScreenGui:TweenPosition(UDim2.new(NormalBounds.X.Scale, NormalBounds.X.Offset-10, 0,0),'Out','Linear',BASE_TWEEN*1.2,true)
  1679. end
  1680.  
  1681. function UnTabify()
  1682.     if IsTabified.Value then
  1683.         IsTabified.Value= false
  1684.         ScreenGui:TweenPosition(UDim2.new(0, 0, 0,0),'Out','Linear',BASE_TWEEN*1.2,true)
  1685.     end
  1686. end
  1687.  
  1688. --[[
  1689.     Does more than it looks like
  1690.     monitors positions of the clipping frames and bottom frames
  1691.     called from EVERYWHERE, too much probably
  1692. --]]
  1693. function UpdateMinimize()
  1694.  
  1695.     if IsMinimized.Value then
  1696.         if IsMaximized.Value then
  1697.             ToggleMaximize()
  1698.         end
  1699.         if not IsTabified.Value then
  1700.             MainFrame.Size = UDim2.new(0.010, HeaderName.TextBounds.X, NormalBounds.Y.Scale,NormalBounds.Y.Offset)
  1701.             MainFrame.Position = UDim2.new(.990, -HeaderName.TextBounds.X, NormalPosition.Y.Scale,0)
  1702.         else
  1703.             MainFrame.Size = NormalBounds
  1704.             MainFrame.Position = NormalPosition
  1705.         end
  1706.         --(#MiddleFrameBackgrounds*MiddleBGTemplate.Size.Y.Scale)
  1707.         BottomClipFrame.Position = UDim2.new(0,0,-1,0)
  1708.         BottomFrame.Position = UDim2.new(0,0,0,0)
  1709.         FocusFrame.Size=UDim2.new(1,0,HeaderFrameHeight,0)
  1710.         ExtendTab.Image = 'rbxasset://textures/ui/expandPlayerList.png'
  1711.     else
  1712.         if not IsMaximized.Value then
  1713.             MainFrame.Size = NormalBounds
  1714.             MainFrame.Position = NormalPosition
  1715.         end
  1716.         --do limiting
  1717.         DefaultBottomClipPos = math.min(math.max(DefaultBottomClipPos,-1),-1+(#MiddleFrameBackgrounds*MiddleBGTemplate.Size.Y.Scale))
  1718.         UpdateScrollPosition()
  1719.  
  1720.         BottomClipFrame.Position=UDim2.new(0,0,DefaultBottomClipPos,0)
  1721.         local bottomPositon = (DefaultBottomClipPos+BottomClipFrame.Size.Y.Scale)
  1722.         BottomFrame.Position=UDim2.new(0,0,bottomPositon,0)
  1723.         FocusFrame.Size=UDim2.new(1,0,bottomPositon + HeaderFrameHeight,0)
  1724.         ExtendTab.Image = 'rbxasset://textures/ui/expandPlayerList.png'
  1725.     end
  1726. end
  1727.  
  1728. --[[
  1729.     Manages the position/size of the mainFrame, swaps out different resolution images for the frame
  1730.     fades in and out the stat names, moves position of headername and header score
  1731. --]]
  1732. function UpdateMaximize()
  1733.     if IsMaximized.Value then
  1734.         for j = 1, #ScoreNames,1 do
  1735.             local scoreval = ScoreNames[j]
  1736.             StatTitles[scoreval['Name'] ]:TweenPosition(UDim2.new(.4+((.6/#ScoreNames)*(j-1))-1,0,0,0),'Out','Linear',BASE_TWEEN,true)
  1737.         end
  1738.        
  1739.         if IsMinimized.Value then
  1740.             ToggleMinimize()
  1741.         else
  1742.             UpdateMinimize()
  1743.         end
  1744.        
  1745.  
  1746.         MainFrame:TweenSizeAndPosition(MaximizedBounds,MaximizedPosition,'Out','Linear',BASE_TWEEN*1.2,true)
  1747.         HeaderScore:TweenPosition(UDim2.new(0,0,HeaderName.Position.Y.Scale,0), "Out", "Linear", BASE_TWEEN*1.2,true)
  1748.         HeaderName:TweenPosition(UDim2.new( - .1, - HeaderScore.TextBounds.x,HeaderName.Position.Y.Scale,0), "Out", "Linear", BASE_TWEEN*1.2,true)
  1749.         for index, i in ipairs(MiddleFrames) do
  1750.  
  1751.             if i:FindFirstChild('ClickListener') then
  1752.                 i.ClickListener.Size = UDim2.new(1,-2,i.ClickListener.Size.Y.Scale, i.ClickListener.Size.Y.Offset)
  1753.             end
  1754.  
  1755.             for j=1, #ScoreNames,1 do
  1756.                 local scoreval = ScoreNames[j]
  1757.                 if i:FindFirstChild(scoreval['Name']) then
  1758.                     i[scoreval['Name']]:TweenPosition(UDim2.new(.4+((.6/#ScoreNames)*(j-1))-1,0,0,0), "Out", "Linear", BASE_TWEEN,true)
  1759.                 end
  1760.             end
  1761.         end
  1762.         for i,entry in ipairs(PlayerFrames) do
  1763.             WaitForChild(entry['Frame'],'TitleFrame').Size=UDim2.new(.38,0,entry['Frame'].TitleFrame.Size.Y.Scale,0)
  1764.         end
  1765.        
  1766.         for i,entry in ipairs(TeamFrames) do
  1767.             WaitForChild(entry['Frame'],'TitleFrame').Size=UDim2.new(.38,0,entry['Frame'].TitleFrame.Size.Y.Scale,0)
  1768.         end
  1769.        
  1770.     else
  1771.         if not IsMinimized.Value then
  1772.             MainFrame:TweenSizeAndPosition(NormalBounds,NormalPosition,'Out','Linear',BASE_TWEEN*1.2,true)
  1773.         end
  1774.         HeaderScore:TweenPosition(UDim2.new(0,0,.4,0), "Out", "Linear", BASE_TWEEN*1.2,true)
  1775.         HeaderName:TweenPosition(UDim2.new(0,0,HeaderName.Position.Y.Scale,0), "Out", "Linear", BASE_TWEEN*1.2,true)
  1776.         for index, i in ipairs(MiddleFrames) do
  1777.         if i:FindFirstChild('ClickListener') then
  1778.                 i.ClickListener.Size = UDim2.new(1, -2,i.ClickListener.Size.Y.Scale, i.ClickListener.Size.Y.Offset)
  1779.                 for j=1, #ScoreNames,1 do
  1780.                     local scoreval = ScoreNames[j]
  1781.                     if i:FindFirstChild(scoreval['Name']) and scoreval['XOffset'] then
  1782.                         --print('updateing stat position: ' .. scoreval['Name'])
  1783.                         i[scoreval['Name']]:TweenPosition(UDim2.new(RightEdgeSpace,-scoreval['XOffset'],0,0), "Out", "Linear", BASE_TWEEN,true)
  1784.                     end
  1785.                 end
  1786.             end
  1787.         end
  1788.        
  1789.         for i,entry in ipairs(TeamFrames) do
  1790.             WaitForChild(entry['Frame'],'TitleFrame').Size=UDim2.new(0,BaseScreenXSize*.9,entry['Frame'].TitleFrame.Size.Y.Scale,0)
  1791.            
  1792.         end
  1793.         for i,entry in ipairs(PlayerFrames) do
  1794.             WaitForChild(entry['Frame'],'TitleFrame').Size=UDim2.new(0,BaseScreenXSize*.9,entry['Frame'].TitleFrame.Size.Y.Scale,0)
  1795.         end
  1796.     end
  1797. end
  1798.  
  1799. function UpdateStatNames()
  1800.     if not AreNamesExpanded.Value or IsMinimized.Value then
  1801.         CloseNames()
  1802.     else
  1803.         ExpandNames()
  1804.     end
  1805. end
  1806.  
  1807. function ExpandNames()
  1808.     if #ScoreNames ~= 0 then
  1809.         for _,i in pairs(StatTitles:GetChildren()) do
  1810.             Spawn(function()TweenProperty(i,'TextTransparency',i.TextTransparency,0,BASE_TWEEN) end)
  1811.         end
  1812.         HeaderFrameHeight=.09
  1813.         --as of writing, this and 'CloseNames' are the only places headerframe is resized
  1814.         HeaderFrame:TweenSizeAndPosition(UDim2.new(HeaderFrame.Size.X.Scale, HeaderFrame.Size.X.Offset, HeaderFrameHeight,0),
  1815.         HeaderFrame.Position,'Out','Linear',BASE_TWEEN*1.2,true)
  1816.         TopClipFrame:TweenPosition(UDim2.new(TopClipFrame.Position.X.Scale,0,HeaderFrameHeight,0),'Out','Linear',BASE_TWEEN*1.2,true)
  1817.         BottomShiftFrame:TweenPosition(UDim2.new(0,0,HeaderFrameHeight,0), "Out", 'Linear', BASE_TWEEN*1.2,true)
  1818.        
  1819.     end
  1820.    
  1821. end
  1822.  
  1823. function CloseNames()
  1824.     if #ScoreNames ~= 0 then
  1825.         HeaderFrameHeight=.07
  1826.         if not (IsMaximized.Value) then
  1827.             for _,i in pairs(StatTitles:GetChildren()) do
  1828.                 Spawn(function()TweenProperty(i,'TextTransparency',i.TextTransparency,1,BASE_TWEEN) end)
  1829.             end
  1830.         end
  1831.         BottomShiftFrame:TweenPosition(UDim2.new(0,0,HeaderFrameHeight,0), "Out", 'Linear', BASE_TWEEN*1.2,true)
  1832.         HeaderFrame:TweenSizeAndPosition(UDim2.new(HeaderFrame.Size.X.Scale, HeaderFrame.Size.X.Offset, HeaderFrameHeight,0),
  1833.         HeaderFrame.Position,'Out','Linear',BASE_TWEEN*1.2,true)
  1834.         TopClipFrame:TweenPosition(UDim2.new(TopClipFrame.Position.X.Scale,0,HeaderFrameHeight,0),'Out','Linear',BASE_TWEEN*1.2,true)
  1835.     end
  1836. end
  1837.  
  1838. function OnScrollWheelMove(direction)
  1839.     if not (IsTabified.Value or IsMinimized.Value or InPopupWaitForClick) then
  1840.         local StartFrame = ListFrame.Position
  1841.         local newFrameY = math.max(math.min(StartFrame.Y.Scale + (direction),GetMaxScroll()),GetMinScroll())
  1842.  
  1843.         ListFrame.Position = UDim2.new(StartFrame.X.Scale,StartFrame.X.Offset,newFrameY,StartFrame.Y.Offset)
  1844.         UpdateScrollPosition()
  1845.     end
  1846. end
  1847.  
  1848. function AttachScrollWheel()
  1849.     if ScrollWheelConnections then return end
  1850.     ScrollWheelConnections = {}
  1851.     table.insert(ScrollWheelConnections,Mouse.WheelForward:connect(function()
  1852.         OnScrollWheelMove(.05)
  1853.     end))
  1854.     table.insert(ScrollWheelConnections,Mouse.WheelBackward:connect(function()
  1855.         OnScrollWheelMove(-.05)
  1856.     end))
  1857. end
  1858.  
  1859. function DetachScrollWheel()
  1860.     if ScrollWheelConnections then
  1861.         for _,i in pairs(ScrollWheelConnections) do
  1862.             i:disconnect()
  1863.         end
  1864.     end
  1865.     ScrollWheelConnections=nil
  1866. end
  1867.  
  1868. FocusFrame.MouseEnter:connect(function()
  1869.     if not (IsMinimized.Value or IsTabified.Value) then
  1870.         AttachScrollWheel()
  1871.     end
  1872. end)
  1873. FocusFrame.MouseLeave:connect(function()
  1874.     --if not (IsMaximized.Value or IsMinimized.Value) then
  1875.         DetachScrollWheel()
  1876.     --end
  1877. end)
  1878.  
  1879.  ------------------------  
  1880.  -- Scroll Bar functions
  1881.  ------------------------
  1882. --[[
  1883.     updates whether the scroll bar should be showing, if it is showing, updates
  1884.     the size of it
  1885. --]]
  1886. function UpdateScrollBarVisibility()
  1887.     if AreAllEntriesOnScreen() then
  1888.         ScrollBar.BackgroundTransparency = 1
  1889.     else
  1890.         ScrollBar.BackgroundTransparency = 0
  1891.         UpdateScrollBarSize()
  1892.     end
  1893. end
  1894. --[[
  1895.     updates size of scrollbar depending on how many entries exist
  1896. --]]
  1897. function UpdateScrollBarSize()
  1898.     local entryListSize = #MiddleFrameBackgrounds * MiddleTemplate.Size.Y.Scale
  1899.     local shownAreaSize = ((BottomClipFrame.Position.Y.Scale) + 1)
  1900.     ScrollBar.Size = UDim2.new(1,0,shownAreaSize/entryListSize,0)
  1901.    
  1902. end
  1903. --[[
  1904.     updates position of listframe so that no gaps at the bottom or top of the list are visible
  1905.     updates position of scrollbar to match what parts of the list are visible
  1906. --]]
  1907. function UpdateScrollPosition()
  1908.     local minPos = GetMinScroll()
  1909.     local maxPos = GetMaxScroll()
  1910.     local scrollLength = maxPos - minPos
  1911.    
  1912.     local yscrollpos=math.max(math.min(ListFrame.Position.Y.Scale,maxPos),minPos)
  1913.     ListFrame.Position=UDim2.new(ListFrame.Position.X.Scale,ListFrame.Position.X.Offset,yscrollpos,ListFrame.Position.Y.Offset)
  1914.    
  1915.     local adjustedLength = 1 - ScrollBar.Size.Y.Scale
  1916.     ScrollBar.Position = UDim2.new(0,0,adjustedLength - (adjustedLength * ((ListFrame.Position.Y.Scale - minPos)/scrollLength)),0)
  1917. end
  1918.  
  1919. --[[
  1920.     WARNING:this is in a working state, but uses massive hacks
  1921.     revize when global input is available
  1922.     Manages scrolling of the playerlist on mouse drag
  1923. --]]
  1924. function StartDrag(entry,startx,starty)
  1925.     local startDragTime = tick()
  1926.         local stopDrag = false
  1927.         local openPanel = true
  1928.         local draggedFrame = WaitForChild(entry['Frame'],'ClickListener')
  1929.         local function dragExit()
  1930.             stopDrag = true
  1931.  
  1932.             if  entry['Player'] and SelectedPlayer and openPanel
  1933.                 and (entry['Player']~=LocalPlayer and (SelectedPlayer.userId>1 and LocalPlayer.userId>1)) then
  1934.                 ActivatePlayerEntryPanel(entry)
  1935.             end
  1936.         end
  1937.         local startY = nil
  1938.         local StartFrame = ListFrame.Position
  1939.         local function dragpoll(nx,ny)
  1940.             if not startY then
  1941.                 startY = AbsoluteToPercent(nx,ny).Y
  1942.             end
  1943.             local nowY = AbsoluteToPercent(nx,ny).Y
  1944.             debugprint('drag dist:'..Vector2.new(startx-nx,starty-ny).magnitude)
  1945.             if Vector2.new(startx-nx,starty-ny).magnitude>MOUSE_DRAG_DISTANCE then
  1946.                 openPanel=false
  1947.             end
  1948.            
  1949.             local newFrameY = math.max(math.min(StartFrame.Y.Scale + (nowY - startY),GetMaxScroll()),GetMinScroll())
  1950.             ListFrame.Position = UDim2.new(StartFrame.X.Scale,StartFrame.X.Offset,newFrameY,StartFrame.Y.Offset)
  1951.             UpdateScrollPosition()
  1952.         end
  1953.         WaitForClick(ScreenGui,dragpoll,dragExit)
  1954. end
  1955.  
  1956.  
  1957. function StartMinimizeDrag()
  1958.     Delay(0,function()
  1959.         local startTime=tick()
  1960.         debugprint('Got Click2')
  1961.         local stopDrag = false
  1962.         local function dragExit()
  1963.             --debugprint('undone click2')
  1964.             if tick()-startTime<.25 then --was click
  1965.                 ToggleMinimize()
  1966.             else --was drag
  1967.                 if (DefaultBottomClipPos >= -1+(#MiddleFrameBackgrounds*MiddleBGTemplate.Size.Y.Scale)) then
  1968.                     DidMinimizeDrag = false
  1969.                 else
  1970.                     DidMinimizeDrag = true                 
  1971.                 end
  1972.                 if IsMinimized.Value then
  1973.                     ToggleMinimize()
  1974.                 end
  1975.             end
  1976.             stopDrag = true
  1977.         end
  1978.         local startY = nil
  1979.         local StartFrame = DefaultBottomClipPos
  1980.         local function dragpoll(nx,ny)
  1981.             if not IsMinimized.Value then
  1982.                
  1983.                 if not startY then
  1984.                     startY = AbsoluteToPercent(nx,ny).Y
  1985.                 end
  1986.                 local nowY = AbsoluteToPercent(nx,ny).Y
  1987.                 local newFrameY
  1988.                 newFrameY = math.min(math.max(StartFrame + (nowY - startY),-1),-1+(#MiddleFrameBackgrounds*MiddleBGTemplate.Size.Y.Scale))
  1989.                 DefaultBottomClipPos = newFrameY
  1990.                 UpdateMinimize()
  1991.                 ScrollBarFrame.Size= UDim2.new(ScrollBarFrame.Size.X.Scale,0,(DefaultBottomClipPos+BottomClipFrame.Size.Y.Scale),0)
  1992.                 ScrollBarFrame.Position= UDim2.new(ScrollBarFrame.Position.X.Scale,0,1-ScrollBarFrame.Size.Y.Scale,0)
  1993.                 UpdateScrollBarSize()
  1994.                 UpdateScrollPosition()
  1995.                 UpdateScrollBarVisibility()
  1996.                
  1997.             end
  1998.         end
  1999.         Spawn(function() WaitForClick(ScreenGui,dragpoll,dragExit) end)
  2000.     end)
  2001.    
  2002. end
  2003.  
  2004.  -------------------------------  
  2005.  -- Input Callback functions
  2006.  -------------------------------
  2007. IsMaximized.Value=false
  2008. IsMinimized.Value=false
  2009. IsMaximized.Changed:connect(UpdateMaximize)
  2010. IsMinimized.Changed:connect(UpdateMinimize)
  2011.  
  2012. ExtendButton.MouseButton1Down:connect(function()
  2013.     if(time() - LastClick < ButtonCooldown) or InPopupWaitForClick then return end
  2014.     LastClick = time()
  2015.     if IsTabified.Value then
  2016.         UnTabify()
  2017.     else
  2018.         StartMinimizeDrag()
  2019.     end
  2020. end)
  2021.  
  2022. MaximizeButton.MouseButton1Click:connect(function()
  2023.     if(time() - LastClick < ButtonCooldown) or InPopupWaitForClick then return end
  2024.     LastClick = time()
  2025.     if IsTabified.Value then
  2026.         UnTabify()
  2027.     elseif not AreNamesExpanded.Value then
  2028.         AreNamesExpanded.Value = true
  2029.         BaseUpdate()
  2030.     else
  2031.         ToggleMaximize()
  2032.     end
  2033. end)
  2034.  
  2035. MaximizeButton.MouseButton2Click:connect(function()
  2036.     if(time() - LastClick < ButtonCooldown) or InPopupWaitForClick then return end
  2037.     LastClick = time()
  2038.     if IsTabified.Value then
  2039.         UnTabify()
  2040.     elseif IsMaximized.Value then
  2041.         ToggleMaximize()
  2042.     elseif AreNamesExpanded.Value then
  2043.         AreNamesExpanded.Value = false
  2044.         BaseUpdate()
  2045.     else
  2046.         Tabify()
  2047.     end
  2048. end)
  2049.  
  2050.  
  2051. -------------------------------  
  2052. -- MiddleFrames management
  2053. -------------------------------
  2054. --[[
  2055.     adds a background frame to the listframe
  2056. --]]
  2057. function AddMiddleBGFrame()
  2058.     local nBGFrame = MiddleBGTemplate:Clone()
  2059.     nBGFrame.Position = UDim2.new(.5,0,((#MiddleFrameBackgrounds) * nBGFrame.Size.Y.Scale),0)
  2060.     nBGFrame.Background.BackgroundTransparency = 1
  2061.  
  2062.     nBGFrame.Parent = ListFrame
  2063.     table.insert(MiddleFrameBackgrounds,nBGFrame)
  2064.    
  2065.     if #MiddleFrameBackgrounds<DefaultListSize and not DidMinimizeDrag then
  2066.         --print('readjusting bottom clip')
  2067.         DefaultBottomClipPos=-1+(#MiddleFrameBackgrounds*MiddleBGTemplate.Size.Y.Scale)
  2068.     end
  2069.    
  2070.     if not IsMinimized.Value  then
  2071.         UpdateMinimize()
  2072.     end
  2073. end
  2074. --[[
  2075.     removes a background from from the listframe
  2076. --]]
  2077. function RemoveMiddleBGFrame()
  2078.     MiddleFrameBackgrounds[#MiddleFrameBackgrounds]:Destroy()
  2079.     table.remove(MiddleFrameBackgrounds,#MiddleFrameBackgrounds)
  2080.     if not IsMinimized.Value then
  2081.         UpdateMinimize()
  2082.     end
  2083. end
  2084. -------------------------------  
  2085. -- Player Callback functions
  2086. -------------------------------
  2087. local FONT_SIZES =
  2088. {'Size8','Size9','Size10','Size11','Size12','Size14','Size24','Size36','Size48'}
  2089. --[[
  2090.     note:should probably set to something other than mainFrame.AbsoluteSize, should work for now
  2091.     if textbounds ever works on textscaled, switch to that :(
  2092. --]]
  2093. function ChangeHeaderName(nname)
  2094.     HeaderName.Text = nname
  2095.     UpdateHeaderNameSize()
  2096. end
  2097.  
  2098. --[[
  2099.     Will fit the player's name to the bounds of the header
  2100.     called on resize of the window and playedr name change events
  2101.     HACK: cannot use 'Textscaled' due to unable to find text bounds when scaled
  2102. --]]
  2103. function UpdateHeaderNameSize()
  2104.     local tHeader= HeaderName:Clone()
  2105.     tHeader.Position=UDim2.new(2,0,2,0)
  2106.     tHeader.Parent=ScreenGui
  2107.     local fSize=7 --Size24 in table
  2108.     tHeader.FontSize=FONT_SIZES[fSize]
  2109.     Delay(.2,function()
  2110.         while tHeader.TextBounds.x==0 do wait(1/30) end
  2111.         while tHeader.TextBounds.x-(NormalBounds.X.Offset) > 1 do
  2112.             fSize=fSize-1
  2113.             tHeader.FontSize=FONT_SIZES[fSize]
  2114.             wait(.2)
  2115.         end
  2116.         HeaderName.FontSize=tHeader.FontSize
  2117.         tHeader:Destroy()
  2118.     end)
  2119. end
  2120. ScreenGui.Changed:connect(UpdateHeaderNameSize)
  2121.  
  2122. --[[
  2123.     called only when the leaderstats object is added to a given player entry
  2124.     removes old stats, adds any existing stats, and sets up listeners for new stats
  2125.     @Args:
  2126.     playerEntry     A reference to the ENTRY(table) of the player who had leaderstats added
  2127. --]]
  2128. function LeaderstatsAdded(playerEntry)
  2129.     --RemoveAllStats(playerEntry)
  2130.     local nplayer = playerEntry['Player']
  2131.     for _,i in pairs(nplayer.leaderstats:GetChildren()) do
  2132.         StatAdded(i,playerEntry)
  2133.     end
  2134.     nplayer.leaderstats.ChildAdded:connect(function(nchild) StatAdded(nchild,playerEntry) end)
  2135.     nplayer.leaderstats.ChildRemoved:connect(function(nchild) StatRemoved(nchild,playerEntry) end)
  2136. end
  2137. --[[
  2138.     called when leaderstats object is removed from play in player entry
  2139.     Note: may not be needed, might be able to just rely on leaderstats added
  2140.     @Args:
  2141.     oldLeaderstats  leaderstats object to be removed
  2142.     playerEntry     A reference to the ENTRY(table) of the player
  2143. --]]
  2144. function LeaderstatsRemoved(oldLeaderstats,playerEntry)
  2145.     while AddingFrameLock do debugprint('waiting to insert '..playerEntry['Player'].Name) wait(1/30) end
  2146.     AddingFrameLock = true
  2147.     RemoveAllStats(playerEntry)
  2148.     AddingFrameLock = false
  2149. end
  2150.  
  2151. function ClosePopUpPanel()
  2152.     if SelectedPlayerEntry then
  2153.         local tframe = SelectedPlayerEntry['Frame']
  2154.         Spawn(function() TweenProperty(tframe,'BackgroundTransparency',.5,1,BASE_TWEEN) end)
  2155.     end
  2156.     PopUpPanel:TweenPosition(UDim2.new(1,0,0,0), "Out", "Linear", BASE_TWEEN,true)
  2157.     wait(.1)
  2158.     InPopupWaitForClick= false
  2159.     SelectedPlayerEntry = nil
  2160. end
  2161.  
  2162. --[[
  2163.     prepares the needed popup to be tweened on screen, and updates the position of the popup clip
  2164.     frame to match the selected player frame's position
  2165. --]]
  2166. function InitMovingPanel( entry, player)
  2167.     PopUpClipFrame.Parent= ScreenGui
  2168.    
  2169.     if PopUpPanel then
  2170.         PopUpPanel:Destroy()
  2171.     end
  2172.     PopUpPanel= PopUpPanelTemplate:Clone()
  2173.     PopUpPanel.Parent= PopUpClipFrame
  2174.    
  2175.     local nextIndex = 2
  2176.     local friendStatus = GetFriendStatus(player)
  2177.     debugprint (tostring(friendStatus))
  2178.     local showRankMenu = IsPersonalServer and LocalPlayer.PersonalServerRank >= PrivilegeLevel['Admin'] and LocalPlayer.PersonalServerRank > SelectedPlayer.PersonalServerRank
  2179.    
  2180.    
  2181.     local ReportPlayerButton = MakePopupButton(PopUpPanel,'Report Player',0)
  2182.     ReportPlayerButton.MouseButton1Click:connect(function() OpenAbuseDialog() end)
  2183.  
  2184.     local enableFriendRequests = true
  2185.  
  2186.     if enableFriendRequests then
  2187.         local FriendPlayerButton = MakePopupButton(PopUpPanel,'Friend',1, not showRankMenu and  friendStatus~=Enum.FriendStatus.FriendRequestReceived)
  2188.         FriendPlayerButton.MouseButton1Click:connect(OnFriendButtonSelect)
  2189.        
  2190.  
  2191.         if friendStatus==Enum.FriendStatus.Friend then
  2192.             FriendPlayerButton:FindFirstChild('ButtonText').Text='UnFriend Player'
  2193.         elseif friendStatus==Enum.FriendStatus.Unknown or friendStatus==Enum.FriendStatus.NotFriend then
  2194.             FriendPlayerButton:FindFirstChild('ButtonText').Text='Send Request'
  2195.         elseif friendStatus==Enum.FriendStatus.FriendRequestSent then
  2196.             FriendPlayerButton:FindFirstChild('ButtonText').Text='Revoke Request'
  2197.         elseif friendStatus==Enum.FriendStatus.FriendRequestReceived then
  2198.             FriendPlayerButton:FindFirstChild('ButtonText').Text='Accept Friend'
  2199.             local FriendRefuseButton = MakePopupButton(PopUpPanel,'Decline Friend',2,not showRankMenu)
  2200.             FriendRefuseButton.MouseButton1Click:connect(OnFriendRefuseButtonSelect)
  2201.             nextIndex=nextIndex+1
  2202.         end
  2203.     end
  2204.  
  2205.     if showRankMenu then
  2206.         local BanPlayerButton = MakePopupButton(PopUpPanel,'Ban',nextIndex)
  2207.         local VisitorButton = MakePopupButton(PopUpPanel,'Visitor',nextIndex+1)
  2208.         local MemberButton = MakePopupButton(PopUpPanel,'Member',nextIndex+2)
  2209.         local AdminButton = MakePopupButton(PopUpPanel,'Admin',nextIndex+3,true)
  2210.        
  2211.         BanPlayerButton.MouseButton1Click:connect(function()
  2212.             OnPrivilegeLevelSelect(player,PrivilegeLevel['Banned'],BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  2213.         end)
  2214.         VisitorButton.MouseButton1Click:connect(function()
  2215.             OnPrivilegeLevelSelect(player,PrivilegeLevel['Visitor'],BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  2216.         end)
  2217.         MemberButton.MouseButton1Click:connect(function()
  2218.             OnPrivilegeLevelSelect(player,PrivilegeLevel['Member'],BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  2219.         end)
  2220.         AdminButton.MouseButton1Click:connect(function()
  2221.             OnPrivilegeLevelSelect(player,PrivilegeLevel['Admin'],BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  2222.         end)
  2223.        
  2224.         HighlightMyRank(SelectedPlayer,BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  2225.     end
  2226.  
  2227.     PopUpPanel:TweenPosition(UDim2.new(0,0,0,0), "Out", "Linear", BASE_TWEEN,true)
  2228.     Delay(0, function()
  2229.         local tconnection
  2230.         tconnection = Mouse.Button1Down:connect(function()
  2231.             tconnection:disconnect()
  2232.             ClosePopUpPanel()
  2233.         end)
  2234.     end)
  2235.    
  2236.     local myFrame = entry['Frame']
  2237.     -- THIS IS GARBAGE.
  2238.     -- if I parent to frame to auto update position, it gets clipped
  2239.     -- sometimes garbage is the only option.
  2240.     Spawn(function()
  2241.         while InPopupWaitForClick do
  2242.             PopUpClipFrame.Position=UDim2.new( 0,myFrame.AbsolutePosition.X-PopUpClipFrame.Size.X.Offset,0,myFrame.AbsolutePosition.Y)
  2243.             wait()
  2244.         end
  2245.     end)
  2246.    
  2247. end
  2248.  
  2249. --[[
  2250.     Called when a player entry in the leaderboard is clicked
  2251.     either will highlight entry and start the drag event, or open a popup menu
  2252.     @Args:
  2253.     entry   the player entry clicked
  2254. --]]
  2255. function OnPlayerEntrySelect(entry,startx,starty)
  2256.  
  2257.     if not InPopupWaitForClick then
  2258.    
  2259.         SelectedPlayerEntry = entry
  2260.         SelectedPlayer = entry['Player']
  2261.        
  2262.         StartDrag(entry,startx,starty)
  2263.     end
  2264.  
  2265.    
  2266. end
  2267.  
  2268. function ActivatePlayerEntryPanel(entry)
  2269.     entry['Frame'].BackgroundColor3 = Color3.new(0,1,1)
  2270.     Spawn(function() TweenProperty(entry['Frame'],'BackgroundTransparency',1,.5,.5) end)
  2271.     InPopupWaitForClick=true
  2272.     InitMovingPanel(entry,entry['Player'])
  2273. end
  2274.  
  2275. --[[
  2276.     the basic update for the playerlist mode's state,
  2277.     assures the order and length of the player frames
  2278. --]]
  2279. function PlayerListModeUpdate()
  2280.     RecreateScoreColumns(PlayerFrames)
  2281.     table.sort(PlayerFrames,PlayerSortFunction)
  2282.     for i,val in ipairs(PlayerFrames) do
  2283.         MiddleFrames[i] = val['Frame']
  2284.     end
  2285.     for i = #PlayerFrames + 1,#MiddleFrames,1 do
  2286.         MiddleFrames[i] = nil
  2287.     end
  2288.     UpdateMinimize()
  2289. end
  2290. --[[
  2291.     this one's a doozie, happens when a player is added to the game
  2292.     inits their player frame and player entry, assigns them to a team if possible,
  2293.     and hooks up their leaderstats
  2294.     @Args:
  2295.     nplayer     new player object to insert
  2296. --]]
  2297. function InsertPlayerFrame(nplayer)
  2298.     while AddingFrameLock do debugprint('waiting to insert '..nplayer.Name) wait(1/30) end
  2299.     AddingFrameLock = true
  2300.    
  2301.     local nFrame = MiddleTemplate:Clone()
  2302.     nFrame.ClickListener.BackgroundColor3 = Color3.new(0,0,0)
  2303.     nFrame.ClickListener.BackgroundTransparency = BACKGROUND_TRANSPARENCY
  2304.     nFrame.ClickListener.AutoButtonColor=false
  2305.  
  2306.     local playerName = nplayer.Name
  2307.     local clansEnabled, clanTag = pcall(function() nplayer:GetClanTag() end)
  2308.     if clansEnabled and clanTag and clanTag ~= "" then
  2309.         playerName = "[" .. tostring(clanTag) .. "] " .. playerName
  2310.     end
  2311.    
  2312.     WaitForChild(WaitForChild(nFrame,'TitleFrame'),'Title').Text = playerName
  2313.    
  2314.     nFrame.Position = UDim2.new(1,0,((#MiddleFrames) * nFrame.Size.Y.Scale),0)
  2315.    
  2316.     local nfriendstatus = GetFriendStatus(nplayer)
  2317.    
  2318.     nFrame:FindFirstChild('BCLabel').Image = getMembershipTypeIcon(nplayer.MembershipType,nplayer.Name)
  2319.     nFrame:FindFirstChild('FriendLabel').Image = getFriendStatusIcon(nfriendstatus)
  2320.     nFrame.Name = nplayer.Name
  2321.     WaitForChild(WaitForChild(nFrame,'TitleFrame'),'Title').Text = playerName
  2322.    
  2323.     --move for bc label
  2324.     nFrame.FriendLabel.Position=nFrame.FriendLabel.Position+UDim2.new(0,17,0,0)
  2325.     nFrame.TitleFrame.Title.Position=nFrame.TitleFrame.Title.Position+UDim2.new(0,17,0,0)
  2326.    
  2327.     if(nFrame:FindFirstChild('FriendLabel').Image ~= '') then
  2328.         nFrame.TitleFrame.Title.Position=nFrame.TitleFrame.Title.Position+UDim2.new(0,17,0,0)
  2329.     end
  2330.    
  2331.     if nplayer.Name == LocalPlayer.Name then
  2332.         nFrame.TitleFrame.Title.Font = 'ArialBold'
  2333.         nFrame.PlayerScore.Font = 'ArialBold'
  2334.         ChangeHeaderName(playerName)
  2335.         local dropShadow = nFrame.TitleFrame.Title:Clone()
  2336.         dropShadow.TextColor3 = Color3.new(0,0,0)
  2337.         dropShadow.TextTransparency=0
  2338.         dropShadow.ZIndex=2
  2339.         dropShadow.Position=nFrame.TitleFrame.Title.Position+UDim2.new(0,1,0,1)
  2340.         dropShadow.Name='DropShadow'
  2341.         dropShadow.Parent= nFrame.TitleFrame
  2342.     else
  2343.         --Delay(2, function () OnFriendshipChanged(nplayer,LocalPlayer:GetFriendStatus(nplayer)) end)
  2344.     end
  2345.     nFrame.TitleFrame.Title.Font = 'ArialBold'
  2346.  
  2347.    
  2348.     nFrame.Parent = ListFrame
  2349.     nFrame.Position = UDim2.new(.5,0,((#MiddleFrames) * nFrame.Size.Y.Scale),0)
  2350.     UpdateMinimize()
  2351.     local nentry = {}
  2352.     nentry['Frame'] = nFrame
  2353.     nentry['Player'] = nplayer
  2354.     nentry['ID'] = AddId
  2355.     AddId = AddId + 1
  2356.     table.insert(PlayerFrames,nentry)
  2357.     if #TeamFrames~=0 then
  2358.        
  2359.         if nplayer.Neutral then
  2360.             nentry['MyTeam'] = nil
  2361.             if not NeutralTeam then
  2362.                 AddNeutralTeam()
  2363.             else
  2364.                 AddPlayerToTeam(NeutralTeam,nentry)
  2365.             end
  2366.            
  2367.         else
  2368.             local addedToTeam=false
  2369.             for i,tval in ipairs(TeamFrames) do
  2370.                 if tval['MyTeam'].TeamColor == nplayer.TeamColor then
  2371.                     AddPlayerToTeam(tval,nentry)
  2372.                     nentry['MyTeam'] = tval
  2373.                     addedToTeam=true
  2374.                 end
  2375.             end
  2376.             if not addedToTeam then
  2377.                 nentry['MyTeam']=nil
  2378.                 if not NeutralTeam then
  2379.                     AddNeutralTeam()
  2380.                 else
  2381.                     AddPlayerToTeam(NeutralTeam,nentry)
  2382.                 end
  2383.                 nentry['MyTeam'] = NeutralTeam
  2384.             end
  2385.         end
  2386.        
  2387.     end
  2388.    
  2389.     if  nplayer:FindFirstChild('leaderstats') then
  2390.         LeaderstatsAdded(nentry)
  2391.     end
  2392.    
  2393.     nplayer.ChildAdded:connect(function(nchild)
  2394.         if nchild.Name == 'leaderstats' then
  2395.             while AddingFrameLock do debugprint('in adding leaderstats lock') wait(1/30) end
  2396.             if not nplayer:FindFirstChild("leaderstats") then return end
  2397.             AddingFrameLock = true
  2398.             LeaderstatsAdded(nentry)
  2399.             AddingFrameLock = false
  2400.         end
  2401.     end)
  2402.  
  2403.     nplayer.ChildRemoved:connect(function (nchild)
  2404.         if nplayer==LocalPlayer and nchild.Name == 'leaderstats' then
  2405.             LeaderstatsRemoved(nchild,nentry)
  2406.         end
  2407.     end)
  2408.     nplayer.Changed:connect(function(prop)PlayerChanged(nentry,prop) end)
  2409.    
  2410.     local listener = WaitForChild(nFrame,'ClickListener')
  2411.     listener.Active = true
  2412.     listener.MouseButton1Down:connect(function(nx,ny) OnPlayerEntrySelect(nentry, nx,ny) end)
  2413.    
  2414.     AddMiddleBGFrame()
  2415.     BaseUpdate()
  2416.     AddingFrameLock = false
  2417. end
  2418.  
  2419. --[[
  2420.     Note:major optimization can be done here
  2421.     removes this player's frame if it exists, calls base update
  2422. --]]
  2423. function RemovePlayerFrame(tplayer)
  2424.     while AddingFrameLock do debugprint('in removing player frame lock') wait(1/30) end
  2425.     AddingFrameLock = true
  2426.    
  2427.     local tteam
  2428.     for i,key in ipairs(PlayerFrames) do
  2429.         if tplayer == key['Player'] then
  2430.             if PopUpClipFrame.Parent == key['Frame'] then
  2431.                 PopUpClipFrame.Parent = nil
  2432.             end
  2433.             key['Frame']:Destroy()
  2434.             tteam=key['MyTeam']
  2435.             table.remove(PlayerFrames,i)
  2436.         end
  2437.     end
  2438.     if tteam then
  2439.         for j,tentry in ipairs(tteam['MyPlayers']) do
  2440.             if tentry['Player'] == tplayer then
  2441.                 RemovePlayerFromTeam(tteam,j)
  2442.             end
  2443.         end
  2444.     end
  2445.  
  2446.     RemoveMiddleBGFrame()
  2447.     UpdateMinimize()
  2448.     BaseUpdate()
  2449.     AddingFrameLock = false
  2450. end
  2451.  
  2452. Players.ChildRemoved:connect(RemovePlayerFrame)
  2453.  
  2454. ----------------------------  
  2455. -- Team Callback Functions
  2456. ----------------------------
  2457. --[[
  2458.     turns a list of team entries with sub lists of players into a single ordered
  2459.     list, in the correct order,and of the correct length
  2460.     @Args:
  2461.     tframes     the team entries to unroll
  2462.     outframes   the list to unroll these entries into
  2463. --]]
  2464. function UnrollTeams(tframes,outframes)
  2465.     local numEntries = 0
  2466.     if NeutralTeam and not NeutralTeam['IsHidden'] then
  2467.         for i,val in ipairs(NeutralTeam['MyPlayers']) do
  2468.             numEntries = numEntries + 1
  2469.             outframes[numEntries] = val['Frame']
  2470.         end
  2471.         numEntries = numEntries + 1
  2472.         outframes[numEntries] = NeutralTeam['Frame']
  2473.     end
  2474.     for i,val in ipairs(tframes) do
  2475.         if not val['IsHidden'] then
  2476.             for j,pval in ipairs(val.MyPlayers) do
  2477.                 numEntries = numEntries + 1
  2478.                 outframes[numEntries] = pval['Frame']
  2479.             end
  2480.             numEntries = numEntries + 1
  2481.             outframes[numEntries] = val['Frame']
  2482.         end
  2483.     end
  2484. -- clear any additional entries from outframes
  2485.     for i = numEntries + 1,#outframes,1 do
  2486.         outframes[i] = nil
  2487.     end
  2488. end
  2489. --[[
  2490.     uses lua's table.sort to sort the teams
  2491. --]]
  2492. function TeamSortFunc(a,b)
  2493.     if a['TeamScore'] == b['TeamScore'] then
  2494.         return a['ID'] < b['ID']
  2495.     end
  2496.     if not a['TeamScore'] then return false end
  2497.     if not b['TeamScore'] then return true end
  2498.     return a['TeamScore'] < b['TeamScore']
  2499.  
  2500. end
  2501. --[[
  2502.     consider adding lock with wait for performance
  2503.     sorts each of the team's player lists induvidually, adds up the team scores.
  2504.     @Args:
  2505.     tentries        table of team entries  
  2506. --]]
  2507. function SortTeams(tentries)
  2508.    
  2509.     for i,val in ipairs(tentries) do
  2510.  
  2511.         table.sort(val['MyPlayers'],PlayerSortFunction)
  2512.         AddTeamScores(val)
  2513.     end
  2514.     table.sort(tentries,TeamSortFunc)
  2515. end
  2516. --[[
  2517.     base update for team mode, adds up the scores of all teams, sorts them,
  2518.     then unrolls them into middleframes
  2519. --]]
  2520. function TeamListModeUpdate()
  2521.     RecreateScoreColumns(PlayerFrames)
  2522.     SortTeams(TeamFrames)
  2523.     if NeutralTeam then
  2524.         AddTeamScores(NeutralTeam)
  2525.         --RecreateScoreColumns(NeutralTeam['MyPlayers'])
  2526.     end
  2527.     UnrollTeams(TeamFrames,MiddleFrames)
  2528. end
  2529. --[[
  2530.     adds up all the score of this team's players to form the team score
  2531.     @Args:
  2532.     team        team entry to sum the scores of
  2533. --]]
  2534. function AddTeamScores(team)
  2535.    
  2536.     for j = 1, #ScoreNames,1 do
  2537.         local i = ScoreNames[j]
  2538.         local tscore = 0
  2539.         for _,j in ipairs(team['MyPlayers']) do
  2540.             local tval = j['Player']:FindFirstChild('leaderstats') and j['Player'].leaderstats:FindFirstChild(i['Name'])
  2541.             if tval and not tval:IsA('StringValue') then
  2542.                 tscore = tscore + GetScoreValue((j['Player'].leaderstats)[i['Name'] ])
  2543.             end
  2544.         end
  2545.         if team['Frame']:FindFirstChild(i['Name']) then
  2546.             --team['Frame'][i['Name'] ].Size = UDim2.new(1 - (ScrollBarFrame.Size.X.Scale * 2),- ((j-1) * SpacingPerStat),1,0)
  2547.             team['Frame'][i['Name'] ].Text = tostring(tscore)
  2548.         end
  2549.     end
  2550.     UpdateMinimize()
  2551.    
  2552. end
  2553.  
  2554. --[[
  2555.     finds previous team this player was on, and if it exists calls removeplayerfromteam
  2556.     @Args
  2557.     entry   Player entry
  2558. --]]
  2559. function FindRemovePlayerFromTeam(entry)
  2560.     if entry['MyTeam'] then
  2561.         for j,oldEntry in ipairs(entry['MyTeam']['MyPlayers']) do
  2562.             if oldEntry['Player'] == entry['Player'] then
  2563.                 RemovePlayerFromTeam(entry['MyTeam'],j)
  2564.                 return
  2565.             end
  2566.         end
  2567.     elseif NeutralTeam then
  2568.         for j,oldEntry in ipairs(NeutralTeam['MyPlayers']) do
  2569.             if oldEntry['Player'] == entry['Player'] then
  2570.                 RemovePlayerFromTeam(NeutralTeam,j)
  2571.                 return
  2572.             end
  2573.         end
  2574.     end
  2575. end
  2576. --[[
  2577.     removes a single player from a given team (not usually called directly)
  2578.     @Args:
  2579.     teamEntry       team entry to remove player from
  2580.     index           index of player in 'MyPlayers' list to remove
  2581. --]]
  2582. function RemovePlayerFromTeam(teamEntry,index)
  2583.     table.remove(teamEntry['MyPlayers'],index)
  2584.     --if teamEntry['AutoHide'] and #teamEntry['MyPlayers'] == 0 then
  2585.     if teamEntry==NeutralTeam and #teamEntry['MyPlayers']==0 then
  2586.         RemoveNeutralTeam()
  2587.     end
  2588. end
  2589. --[[
  2590.     adds player entry entry to teamentry
  2591.     removes them from any previous team
  2592.     @Args:
  2593.     teamEntry       entry of team to add player to
  2594.     entry           player entry to add to this team
  2595. --]]
  2596. function AddPlayerToTeam(teamEntry,entry)
  2597.     FindRemovePlayerFromTeam(entry)
  2598.     table.insert(teamEntry['MyPlayers'],entry)
  2599.     entry['MyTeam'] = teamEntry
  2600.     if teamEntry['IsHidden'] then
  2601.         teamEntry['Frame'].Parent = ListFrame
  2602.         AddMiddleBGFrame()
  2603.     end
  2604.     teamEntry['IsHidden'] = false
  2605. end
  2606.  
  2607.  
  2608. function SetPlayerToTeam(entry)
  2609.     FindRemovePlayerFromTeam(entry)
  2610.     -- check to see if team exists, if it does add to that team
  2611.     local setToTeam = false
  2612.     for i,tframe in ipairs(TeamFrames) do
  2613.     -- add my entry on the new team
  2614.     if tframe['MyTeam'].TeamColor == entry['Player'].TeamColor then
  2615.             AddPlayerToTeam(tframe,entry)
  2616.             setToTeam = true
  2617.         end
  2618.     end
  2619.     -- if player was set to an invalid team, then set it back to neutral
  2620.     if not setToTeam and #(game:GetService("Teams"):GetTeams())>0 then
  2621.         debugprint(entry['Player'].Name..'could not find team')
  2622.         entry['MyTeam']=nil
  2623.         if not NeutralTeam then
  2624.             AddNeutralTeam()
  2625.         else AddPlayerToTeam(NeutralTeam,entry) end
  2626.     end
  2627. end
  2628.  
  2629. --[[
  2630.     Note:another big one, consiter breaking up
  2631.     called when any children of player changes
  2632.     handles 'Neutral', teamColor, Name and MembershipType changes
  2633.     @Args
  2634.     entry       Player entry changed
  2635.     property    name of property changed
  2636. --]]
  2637. function PlayerChanged(entry, property)
  2638.     while PlayerChangedLock do
  2639.         debugprint('in playerchanged lock')
  2640.         wait(1/30)
  2641.     end
  2642.     PlayerChangedLock=true
  2643.     if property == 'Neutral' then
  2644.         -- if player changing to neutral
  2645.         if entry['Player'].Neutral and #(game:GetService("Teams"):GetTeams())>0 then
  2646.             debugprint(entry['Player'].Name..'setting to neutral')
  2647.             FindRemovePlayerFromTeam(entry)
  2648.             entry['MyTeam']=nil
  2649.             if not NeutralTeam then
  2650.                 debugprint(entry['Player'].Name..'creating neutral team')
  2651.                 AddNeutralTeam()
  2652.             else
  2653.                 debugprint(entry['Player'].Name..'adding to neutral team')
  2654.                 AddPlayerToTeam(NeutralTeam,entry)
  2655.             end
  2656.         elseif #(game:GetService("Teams"):GetTeams())>0 then -- else player switching to a team, or a weird edgecase
  2657.             debugprint(entry['Player'].Name..'has been set non-neutral')
  2658.             SetPlayerToTeam(entry)
  2659.         end
  2660.         BaseUpdate()
  2661.     elseif property == 'TeamColor' and not entry['Player'].Neutral and entry['Player'] ~= entry['MyTeam'] then
  2662.         debugprint(entry['Player'].Name..'setting to new team')
  2663.         SetPlayerToTeam(entry)
  2664.         BaseUpdate()
  2665.     elseif property == 'Name' or property == 'MembershipType' then
  2666.         entry['Frame']:FindFirstChild('BCLabel').Image = getMembershipTypeIcon(entry['Player'].MembershipType,entry['Player'].Name)
  2667.         entry['Frame'].Name = entry['Player'].Name
  2668.         entry['Frame'].TitleFrame.Title.Text = entry['Player'].Name
  2669.         if(entry['Frame'].BCLabel.Image ~= '') then
  2670.             entry['Frame'].TitleFrame.Title.Position=UDim2.new(.01, 30, .1, 0)
  2671.         end
  2672.         if entry['Player'] == LocalPlayer then
  2673.             entry['Frame'].TitleFrame.DropShadow.Text= entry['Player'].Name
  2674.             ChangeHeaderName(entry['Player'].Name)
  2675.         end
  2676.         BaseUpdate()
  2677.     end
  2678.     PlayerChangedLock=false
  2679. end
  2680.  
  2681. function OnFriendshipChanged(player,friendStatus)
  2682. --[[
  2683.     Delay(.5,function()
  2684.         debugprint('friend status changed for:'..player.Name .." ".. tostring(friendStatus) .. " vs " .. tostring(GetFriendStatus(player)) )
  2685.         for _, entry in ipairs(PlayerFrames) do
  2686.             if entry['Player']==player then
  2687.                 local nicon = getFriendStatusIcon(friendStatus)
  2688.                 if nicon == '' and entry['Frame'].FriendLabel.Image ~= '' then
  2689.                     entry['Frame'].TitleFrame.Title.Position=entry['Frame'].TitleFrame.Title.Position-UDim2.new(0,17,0,0)
  2690.                 elseif nicon ~= '' and entry['Frame'].FriendLabel.Image == '' then
  2691.                     entry['Frame'].TitleFrame.Title.Position=entry['Frame'].TitleFrame.Title.Position+UDim2.new(0,17,0,0)
  2692.                     debugprint('confirmed status:'..player.Name)
  2693.                 end
  2694.                 entry['Frame'].FriendLabel.Image = nicon
  2695.                 return
  2696.             end
  2697.         end
  2698.     end)]]
  2699. end
  2700.  
  2701. --LocalPlayer.FriendStatusChanged:connect(OnFriendshipChanged)
  2702.  
  2703. --[[
  2704.     adds a neutral team if nessisary
  2705.     Note: a lot of redundant code here, might want to refactor to share a function with insertteamframe
  2706. --]]
  2707. function AddNeutralTeam()
  2708.     while NeutralTeamLock do debugprint('in neutral team 2 lock') wait() end
  2709.     NeutralTeamLock = true
  2710.    
  2711.     local defaultTeam = Instance.new('Team')
  2712.     defaultTeam.TeamColor = BrickColor.new('White')
  2713.     defaultTeam.Name = 'Neutral'
  2714.     local nentry = {}
  2715.     nentry['MyTeam'] = defaultTeam
  2716.     nentry['MyPlayers'] = {}
  2717.     nentry['Frame'] = MiddleTemplate:Clone()
  2718.     WaitForChild(WaitForChild(nentry['Frame'],'TitleFrame'),'Title').Text = defaultTeam.Name
  2719.     nentry['Frame'].TitleFrame.Position=UDim2.new(nentry['Frame'].TitleFrame.Position.X.Scale,nentry['Frame'].TitleFrame.Position.X.Offset,.1,0)
  2720.     nentry['Frame'].TitleFrame.Size=UDim2.new(nentry['Frame'].TitleFrame.Size.X.Scale,nentry['Frame'].TitleFrame.Size.X.Offset,.8,0)
  2721.     nentry['Frame'].TitleFrame.Title.Font = 'ArialBold'
  2722.     nentry['Frame'].Position = UDim2.new(1,0,((#MiddleFrames) * nentry['Frame'].Size.Y.Scale),0)
  2723.     WaitForChild(nentry['Frame'],'ClickListener').MouseButton1Down:connect(function(nx,ny) StartDrag(nentry,nx,ny) end)
  2724.     nentry['Frame'].ClickListener.BackgroundColor3 = Color3.new(1,1,1)
  2725.     nentry['Frame'].ClickListener.BackgroundTransparency = BACKGROUND_TRANSPARENCY
  2726.     nentry['Frame'].ClickListener.AutoButtonColor=false
  2727.     nentry['AutoHide'] = true
  2728.     nentry['IsHidden'] = true
  2729.     for _,i in pairs(PlayerFrames) do
  2730.         if i['Player'].Neutral or not i['MyTeam'] then
  2731.             AddPlayerToTeam(nentry,i)
  2732.         end
  2733.     end
  2734.     if #nentry['MyPlayers'] > 0 then
  2735.         NeutralTeam = nentry
  2736.         UpdateMinimize()
  2737.         BaseUpdate()
  2738.     end
  2739.     NeutralTeamLock = false
  2740. end
  2741.  
  2742. function RemoveNeutralTeam()
  2743.     while NeutralTeamLock do debugprint('in neutral team lock') wait() end
  2744.     NeutralTeamLock = true
  2745.     NeutralTeam['Frame']:Destroy()
  2746.     NeutralTeam=nil
  2747.     RemoveMiddleBGFrame()
  2748.     NeutralTeamLock = false
  2749. end
  2750.  
  2751. --[[
  2752.    
  2753. --]]
  2754. function TeamScoreChanged(entry,nscore)
  2755.     WaitForChild(entry['Frame'],'PlayerScore').Text = tostring(nscore)
  2756.     entry['TeamScore'] = nscore
  2757. end
  2758. --[[
  2759.     called when child added to a team, used for autohide functionality
  2760.     Note: still has teamscore, consiter removing
  2761. --]]
  2762. function TeamChildAdded(entry,nchild)
  2763.     if nchild.Name == 'AutoHide' then
  2764.         entry['AutoHide'] = true
  2765.     elseif nchild.Name == 'TeamScore' then
  2766.         WaitForChild(entry['Frame'],'PlayerScore').Text = tostring(nchild.Value)
  2767.         entry['TeamScore'] = nchild.Value
  2768.         nchild.Changed:connect(function() TeamScoreChanged(entry,nchild.Value) end)
  2769.     end
  2770. end
  2771. --[[
  2772.     called when child added to a team, used for autohide functionality
  2773.     Note: still has teamscore, consiter removing
  2774. --]]
  2775. function TeamChildRemoved(entry,nchild)
  2776.     if nchild.Name == 'AutoHide' then
  2777.         entry['AutoHide'] = false
  2778.     elseif nchild.Name == 'TeamScore' then
  2779.         WaitForChild(entry['Frame'],'PlayerScore').Text = ""
  2780.         entry['TeamScore'] = nil
  2781.     end
  2782. end
  2783.  
  2784. function TeamChanged(entry, property)
  2785.     if property=='Name' then
  2786.         WaitForChild(WaitForChild(entry['Frame'],'TitleFrame'),'Title').Text = entry['MyTeam'].Name
  2787.        
  2788.     elseif property=='TeamColor' then
  2789.         entry['Frame'].ClickListener.BackgroundColor3 = entry['MyTeam'].TeamColor.Color
  2790.        
  2791.         for _,i in pairs(TeamFrames) do
  2792.             if i['MyTeam'].TeamColor == entry['MyTeam'] then
  2793.                 RemoveTeamFrame(entry['MyTeam'])    --NO DUPLICATE TEAMS!
  2794.             end
  2795.         end
  2796.        
  2797.         entry['MyPlayers']={}
  2798.        
  2799.         for _,i in pairs(PlayerFrames) do
  2800.             SetPlayerToTeam(i)
  2801.         end
  2802.         BaseUpdate()
  2803.     end
  2804. end
  2805.  
  2806. --[[
  2807.     creates team entry and frame for this team, sets up listeners for this team
  2808.     adds any players intended for this team,Creates neutral team if this is the first team added
  2809.     Note:might be best to break this into multiple functions to simplify
  2810.     @Args:
  2811.     nteam   new team object added
  2812. --]]
  2813. function InsertTeamFrame(nteam)
  2814.     while AddingFrameLock do debugprint('in adding team frame lock') wait(1/30) end
  2815.     AddingFrameLock = true
  2816.     --for _,i in pairs(TeamFrames) do
  2817.     local nentry = {}
  2818.     nentry['MyTeam'] = nteam
  2819.     nentry['MyPlayers'] = {}
  2820.     nentry['Frame'] = MiddleTemplate:Clone()
  2821.     WaitForChild(WaitForChild(nentry['Frame'],'TitleFrame'),'Title').Text = nteam.Name
  2822.     nentry['Frame'].TitleFrame.Title.Font = 'ArialBold'
  2823.     nentry['Frame'].TitleFrame.Title.FontSize = 'Size18'
  2824.     nentry['Frame'].Position = UDim2.new(0.5,0,((#MiddleFrames) * nentry['Frame'].Size.Y.Scale),0)
  2825.     WaitForChild(nentry['Frame'],'ClickListener').MouseButton1Down:connect(function(nx,ny) StartDrag(nentry,nx,ny) end)
  2826.     nentry['Frame'].ClickListener.BackgroundColor3 = nteam.TeamColor.Color
  2827.     nentry['Frame'].ClickListener.BackgroundTransparency = BACKGROUND_TRANSPARENCY
  2828.     nentry['Frame'].ClickListener.AutoButtonColor=false
  2829.     AddId = AddId + 1
  2830.     nentry['ID'] = AddId
  2831.     nentry['AutoHide'] = false
  2832.     if nteam:FindFirstChild('AutoHide') then
  2833.         nentry['AutoHide'] = true
  2834.     end
  2835.     if nteam:FindFirstChild('TeamScore') then
  2836.         TeamChildAdded(nentry,nteam.TeamScore)
  2837.        
  2838.     end
  2839.    
  2840.     nteam.ChildAdded:connect(function(nchild) TeamChildAdded(nentry,nchild) end)
  2841.     nteam.ChildRemoved:connect(function(nchild) TeamChildRemoved(nentry,nchild) end)
  2842.     nteam.Changed:connect(function(prop) TeamChanged(nentry,prop) end)
  2843.    
  2844.     for _,i in pairs(PlayerFrames) do
  2845.         if not i['Player'].Neutral and i['Player'].TeamColor == nteam.TeamColor then
  2846.             AddPlayerToTeam(nentry,i)
  2847.         end
  2848.     end
  2849.     nentry['IsHidden'] = false
  2850.     if not nentry['AutoHide'] or #nentry['MyPlayers'] > 0 then
  2851.         nentry['Frame'].Parent = ListFrame
  2852.         AddMiddleBGFrame()
  2853.     else
  2854.         nentry['IsHidden'] = true
  2855.         nentry['Frame'].Parent = nil
  2856.     end
  2857.  
  2858.     table.insert(TeamFrames,nentry)
  2859.     UpdateMinimize()
  2860.     BaseUpdate()
  2861.     if #TeamFrames == 1 and not NeutralTeam then
  2862.         AddNeutralTeam()
  2863.     end
  2864.     AddingFrameLock = false
  2865. end
  2866. --[[
  2867.     removes team from team list
  2868.     @Args:
  2869.     nteam       Teamobject to remove
  2870. --]]
  2871. function RemoveTeamFrame(nteam)
  2872.     while AddingFrameLock do debugprint('in removing team frame lock') wait(1/30) end
  2873.     AddingFrameLock = true
  2874.     if IsMinimized.Value then
  2875.     end
  2876.     local myEntry
  2877.     for i,key in ipairs(TeamFrames) do
  2878.         if nteam == key['MyTeam'] then
  2879.             myEntry = key
  2880.             key['Frame']:Destroy()
  2881.             table.remove(TeamFrames,i)
  2882.         end
  2883.     end
  2884.     if #TeamFrames==0 then
  2885.         debugprint('removeteamframe, remove neutral')
  2886.         if NeutralTeam then
  2887.             RemoveNeutralTeam()
  2888.         end
  2889.     end
  2890.     for i,key in ipairs(myEntry['MyPlayers']) do
  2891.         RemovePlayerFromTeam(myEntry,i)
  2892.         PlayerChanged(key, 'TeamColor')
  2893.     end
  2894.     RemoveMiddleBGFrame()
  2895.     BaseUpdate()
  2896.     AddingFrameLock = false
  2897. end
  2898.  
  2899. function TeamAdded(nteam)
  2900.     InsertTeamFrame(nteam)
  2901. end
  2902.  
  2903. function TeamRemoved(nteam)
  2904.     RemoveTeamFrame(nteam)
  2905. end
  2906.  ---------------------------------
  2907. --[[
  2908.     called when ANYTHING changes the state of the playerlist
  2909.     re-sorts everything,assures correct positions of all elements
  2910. --]]
  2911. function BaseUpdate()
  2912.     while BaseUpdateLock do debugprint('in baseupdate lock') wait(1/30) end
  2913.     BaseUpdateLock = true
  2914.     --print ('baseupdate')
  2915.     UpdateStatNames()
  2916.    
  2917.     if #TeamFrames == 0 and not NeutralTeam then
  2918.         PlayerListModeUpdate()
  2919.     else
  2920.         TeamListModeUpdate()
  2921.     end
  2922.     for i,key in ipairs(MiddleFrames) do
  2923.         if key.Parent ~= nil then
  2924.             key.Position = UDim2.new(.5,0,((#MiddleFrames - (i)) * key.Size.Y.Scale),0)
  2925.         end
  2926.     end
  2927.     if not IsMinimized.Value and #MiddleFrames>DefaultEntriesOnScreen then
  2928.         UpdateScrollPosition()
  2929.     end
  2930.    
  2931.     UpdateMinimize()
  2932.  
  2933.     UpdateScrollBarSize()
  2934.     UpdateScrollPosition()
  2935.  
  2936.     UpdateScrollBarVisibility()
  2937.     --debugprint('EndBaseUpdate')
  2938.     BaseUpdateLock = false
  2939. end
  2940.  
  2941. --[[
  2942.     code for attaching tab key to maximizing player list
  2943. --]]
  2944. --game:GetService("GuiService"):AddKey("\t")
  2945. local LastTabTime = time()
  2946.  
  2947. game:GetService("Players").LocalPlayer:GetMouse().KeyDown:connect(
  2948.  
  2949. function(key)--[[
  2950.     if key:byte() == 9 then
  2951.        
  2952.         debugprint('caught tab key')
  2953.         local modalCheck, isModal = pcall(function() return game:GetService("GuiService").IsModalDialog end)
  2954.         if modalCheck == false or (modalCheck and isModal == false) then
  2955.             if time() - LastTabTime > 0.4 then
  2956.                 LastTabTime = time()
  2957.                 if IsTabified.Value then
  2958.                     if not IsMaximized.Value then
  2959.                         ScreenGui:TweenPosition(UDim2.new(0, 0, 0,0),'Out','Linear',BASE_TWEEN*1.2,true)
  2960.                         IsMaximized.Value = true
  2961.                     else
  2962.                         ScreenGui:TweenPosition(UDim2.new(NormalBounds.X.Scale, NormalBounds.X.Offset-10, 0,0),'Out','Linear',BASE_TWEEN*1.2,true)
  2963.                         IsMaximized.Value = false
  2964.                         IsMinimized.Value=true
  2965.                     end
  2966.                 else
  2967.                     ToggleMaximize()
  2968.                 end
  2969.                
  2970.             end
  2971.         end
  2972.     end]]
  2973. end)
  2974.  
  2975.  
  2976. function PlayersChildAdded(tplayer)
  2977.     if tplayer:IsA('Player') then
  2978.         Spawn(function() debugPlayerAdd(tplayer) end)
  2979.     else
  2980.         BlowThisPopsicleStand()
  2981.     end
  2982. end
  2983.  
  2984. function coreGuiChanged(coreGuiType, enabled)
  2985.     --[[
  2986.     if coreGuiType == Enum.CoreGuiType.All or coreGuiType == Enum.CoreGuiType.PlayerList then
  2987.         MainFrame.Visible = enabled
  2988.     end
  2989. ]]
  2990. end
  2991.  
  2992. function TeamsChildAdded(nteam)
  2993.     if nteam:IsA('Team') then
  2994.         TeamAdded(nteam)
  2995.     else
  2996.         BlowThisPopsicleStand()
  2997.     end
  2998. end
  2999.  
  3000. function TeamsChildRemoved(nteam)
  3001.     if nteam:IsA('Team')  then
  3002.         TeamRemoved(nteam)
  3003.     else
  3004.         BlowThisPopsicleStand()
  3005.     end
  3006. end
  3007.  
  3008.  ----------------------------  
  3009.  -- Hookups and initialization
  3010.  ----------------------------  
  3011. function debugPlayerAdd(p)
  3012.     InsertPlayerFrame(p)
  3013. end
  3014.  
  3015. pcall(function()
  3016.     coreGuiChanged(Enum.CoreGuiType.PlayerList, Game:GetService("StarterGui"):GetCoreGuiEnabled(Enum.CoreGuiType.PlayerList))
  3017.     Game:GetService("StarterGui").CoreGuiChangedSignal:connect(coreGuiChanged)
  3018. end)
  3019.  
  3020. while not game:GetService('Teams') do wait(1/30) debugprint('Waiting For Teams') end
  3021. for _,i in pairs(game:GetService("Teams"):GetTeams()) do TeamAdded(i) end
  3022. for _,i in pairs(Players:GetPlayers()) do Spawn(function() debugPlayerAdd(i) end) end
  3023.  
  3024. game:GetService("Teams").ChildAdded:connect(TeamsChildAdded)
  3025. game:GetService("Teams").ChildRemoved:connect(TeamsChildRemoved)
  3026. Players.ChildAdded:connect(PlayersChildAdded)
  3027.  
  3028. --InitReportAbuse()
  3029. AreNamesExpanded.Value = true
  3030. BaseUpdate()
  3031.  
  3032.  
  3033.  
  3034. --UGGGLY,find a better way later
  3035. wait(2)
  3036. IsPersonalServer= not not game:GetService("Workspace"):FindFirstChild("PSVariable")
  3037.  
  3038.  ----------------------------  
  3039.  -- Running Logic
  3040.  ----------------------------
  3041.  
  3042.  --debug stuffs, will only run for 'newplayerlistisbad'
  3043.  if LocalPlayer.Name == 'newplayerlistisbad' or LocalPlayer.Name == 'imtotallyadmin' then
  3044.     debugFrame.Parent = ScreenGui
  3045.     Spawn(function()
  3046.         while true do
  3047.             local str_players=''
  3048.             for _,i in pairs(game:GetService("Players"):GetPlayers()) do
  3049.                 str_players= str_players .." " .. i.Name
  3050.             end
  3051.             debugplayers.Text=str_players
  3052.             wait(.5)
  3053.         end
  3054.     end)
  3055.  end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement