Advertisement
Guest User

ROBLOX CoreGui Code

a guest
Mar 7th, 2015
2,036
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 61.19 KB | None | 0 0
  1. --[[
  2. // FileName: PlayerlistModule.lua
  3. // Version 1.0
  4. // Written by: jmargh
  5. // Description: Implementation of in game player list and leaderboard
  6. ]]
  7. local CoreGui = game:GetService'CoreGui'
  8. local GuiService = game:GetService('GuiService') -- NOTE: Can only use in core scripts
  9. local UserInputService = game:GetService('UserInputService')
  10. local HttpService = game:GetService('HttpService')
  11. local HttpRbxApiService = game:GetService('HttpRbxApiService')
  12. local Players = game:GetService('Players')
  13. local TeamsService = game:FindService('Teams')
  14. local RobloxReplicatedStorage = nil -- NOTE: Can only use in core scripts
  15.  
  16. local RbxGuiLibrary = nil
  17. if LoadLibrary then
  18. RbxGuiLibrary = LoadLibrary("RbxGui")
  19. end
  20.  
  21. while not Players.LocalPlayer do
  22. wait()
  23. end
  24. local Player = Players.LocalPlayer
  25. local RobloxGui = CoreGui:WaitForChild('RobloxGui')
  26.  
  27. --[[ Fast Flags ]]--
  28. local maxFriendSuccess, isMaxFriendsCountEnabled = pcall(function() return settings():GetFFlag("MaxFriendsCount") end)
  29. local followersSuccess, isFollowersEnabled = pcall(function() return settings():GetFFlag("LuaFollowers") end)
  30. local newNotificationsSuccess, newNotificationsEnabled = pcall(function() return settings():GetFFlag("NewNotificationsScript") end)
  31. local newSettingsSuccess, newSettingsEnabled = pcall(function() return settings():GetFFlag("NewMenuSettingsScript") end)
  32. local serverCoreScriptsSuccess, serverCoreScriptsEnabled = pcall(function() return settings():GetFFlag("UseServerCoreScripts") end)
  33. --
  34. local IsMaxFriendsCount = maxFriendSuccess and isMaxFriendsCountEnabled
  35. local IsFollowersEnabled = followersSuccess and isFollowersEnabled
  36. local IsNewNotifications = newNotificationsSuccess and newNotificationsEnabled
  37. local IsNewSettings = newSettingsSuccess and newSettingsEnabled
  38. local IsServerCoreScripts = serverCoreScriptsSuccess and serverCoreScriptsEnabled
  39.  
  40. --[[ Start Module ]]--
  41. local Playerlist = {}
  42.  
  43. --[[ Public Event API ]]--
  44. -- Parameters: Sorted Array - see ClientStats below
  45. Playerlist.OnLeaderstatsChanged = Instance.new('BindableEvent')
  46. -- Parameters: nameOfStat(string), formatedStringOfStat(string)
  47. Playerlist.OnStatChanged = Instance.new('BindableEvent')
  48.  
  49. --[[ Client Stat Table ]]--
  50. -- Sorted Array of tables
  51. local ClientStats = {}
  52. -- Fields
  53. -- Name: String the developer has given the stat
  54. -- Text: Formated string of the stat value
  55.  
  56. --[[ Script Variables ]]--
  57. local MyPlayerEntry = nil
  58. local PlayerEntries = {}
  59. local GameStats = {}
  60. local StatAddId = 0
  61. local TeamEntries = {}
  62. local TeamAddId = 0
  63. local NeutralTeam = nil
  64. local IsShowingNeutralFrame = false
  65. local LastSelectedFrame = nil
  66. local LastSelectedPlayer = nil
  67. local MinContainerSize = UDim2.new(0, 200, 0.5, 0)
  68. local PlayerEntrySizeY = 24
  69. local TeamEntrySizeY = 18
  70. local NameEntrySizeX = 170
  71. local StatEntrySizeX = 75
  72. local IsSmallScreenDevice = UserInputService.TouchEnabled and GuiService:GetScreenResolution().Y <= 500
  73.  
  74. --[[ Bindables ]]--
  75. local BinbableFunction_SendNotification = RobloxGui:FindFirstChild('SendNotification')
  76.  
  77. --[[ Remotes ]]--
  78. local RemoteEvent_OnNewFollower = nil
  79. if IsServerCoreScripts then
  80. RobloxReplicatedStorage = game:GetService('RobloxReplicatedStorage')
  81. RemoteEvent_OnNewFollower = RobloxReplicatedStorage:WaitForChild('OnNewFollower')
  82. end
  83.  
  84. local IsPersonalServer = false
  85. local PersonalServerService = nil
  86. if workspace:FindFirstChild('PSVariable') then
  87. IsPersonalServer = true
  88. PersonalServerService = game:GetService('PersonalServerService')
  89. end
  90. workspace.ChildAdded:connect(function(child)
  91. if child.Name == 'PSVariable' and child:IsA('BoolValue') then
  92. IsPersonalServer = true
  93. PersonalServerService = game:GetService('PersonalServerService')
  94. end
  95. end)
  96.  
  97. --Report Abuse
  98. local AbusingPlayer = nil
  99. local AbuseReason = nil
  100.  
  101. --[[ Constants ]]--
  102. local ENTRY_PAD = 2
  103. local BG_TRANSPARENCY = 0.5
  104. local BG_COLOR = Color3.new(28/255, 28/255, 28/255)
  105. local TEXT_STROKE_TRANSPARENCY = 0.75
  106. local TEXT_COLOR = Color3.new(1, 1, 243/255)
  107. local TEXT_STROKE_COLOR = Color3.new(34/255, 34/255, 34/255)
  108. local TWEEN_TIME = 0.15
  109. local MAX_LEADERSTATS = 4
  110. local MAX_STR_LEN = 12
  111. local MAX_FRIEND_COUNT = 200
  112.  
  113. local ADMINS = { -- Admins with special icons
  114. ['7210880'] = 'http://www.roblox.com/asset/?id=134032333', -- Jeditkacheff
  115. ['13268404'] = 'http://www.roblox.com/asset/?id=113059239', -- Sorcus
  116. ['261'] = 'http://www.roblox.com/asset/?id=105897927', -- shedlestky
  117. ['20396599'] = 'http://www.roblox.com/asset/?id=161078086', -- Robloxsai
  118. }
  119.  
  120. local ABUSES = {
  121. "Swearing",
  122. "Bullying",
  123. "Scamming",
  124. "Dating",
  125. "Cheating/Exploiting",
  126. "Personal Questions",
  127. "Offsite Links",
  128. "Bad Username",
  129. }
  130.  
  131. local FOLLOWER_STATUS = {
  132. FOLLOWER = 0,
  133. FOLLOWING = 1,
  134. MUTUAL = 2,
  135. }
  136.  
  137. local PRIVILEGE_LEVEL = {
  138. OWNER = 255,
  139. ADMIN = 240,
  140. MEMBER = 128,
  141. VISITOR = 10,
  142. BANNED = 0,
  143. }
  144.  
  145. --[[ Images ]]--
  146. local CHAT_ICON = 'rbxasset://textures/ui/chat_teamButton.png'
  147. local ADMIN_ICON = 'rbxasset://textures/ui/icon_admin-16.png'
  148. local PLACE_OWNER_ICON = 'rbxasset://textures/ui/icon_placeowner.png'
  149. local BC_ICON = 'rbxasset://textures/ui/icon_BC-16.png'
  150. local TBC_ICON = 'rbxasset://textures/ui/icon_TBC-16.png'
  151. local OBC_ICON = 'rbxasset://textures/ui/icon_OBC-16.png'
  152. local FRIEND_ICON = 'rbxasset://textures/ui/icon_friends_16.png'
  153. local FRIEND_REQUEST_ICON = 'rbxasset://textures/ui/icon_friendrequestsent_16.png'
  154. local FRIEND_RECEIVED_ICON = 'rbxasset://textures/ui/icon_friendrequestrecieved-16.png'
  155.  
  156. local FOLLOWER_ICON = 'rbxasset://textures/ui/icon_follower-16.png'
  157. local FOLLOWING_ICON = 'rbxasset://textures/ui/icon_following-16.png'
  158. local MUTUAL_FOLLOWING_ICON = 'rbxasset://textures/ui/icon_mutualfollowing-16.png'
  159.  
  160. local FRIEND_IMAGE = 'http://www.roblox.com/thumbs/avatar.ashx?userId='
  161.  
  162. --[[ Helper Functions ]]--
  163. local function clamp(value, min, max)
  164. if value < min then
  165. value = min
  166. elseif value > max then
  167. value = max
  168. end
  169.  
  170. return value
  171. end
  172.  
  173. local function getFriendStatus(selectedPlayer)
  174. if selectedPlayer == Player then
  175. return Enum.FriendStatus.NotFriend
  176. else
  177. local success, result = pcall(function()
  178. -- NOTE: Core script only
  179. return Player:GetFriendStatus(selectedPlayer)
  180. end)
  181. if success then
  182. return result
  183. else
  184. return Enum.FriendStatus.NotFriend
  185. end
  186. end
  187. end
  188.  
  189. -- Returns whether followerUserId is following userId
  190. local function isFollowing(userId, followerUserId)
  191. local apiPath = "user/following-exists?userId="
  192. local params = userId.."&followerUserId="..followerUserId
  193. local success, result = pcall(function()
  194. return HttpRbxApiService:GetAsync(apiPath..params, true)
  195. end)
  196. if not success then
  197. print("isFollowing() failed because", result)
  198. return false
  199. end
  200.  
  201. -- can now parse web response
  202. result = HttpService:JSONDecode(result)
  203. return result["success"] and result["isFollowing"]
  204. end
  205.  
  206. local function getFollowerStatus(selectedPlayer)
  207. if selectedPlayer == Player then
  208. return nil
  209. end
  210.  
  211. -- ignore guest
  212. if selectedPlayer.userId <= 0 then
  213. return
  214. end
  215.  
  216. local myUserId = tostring(Player.userId)
  217. local theirUserId = tostring(selectedPlayer.userId)
  218.  
  219. local isFollowingMe = isFollowing(myUserId, theirUserId)
  220. local isFollowingThem = isFollowing(theirUserId, myUserId)
  221.  
  222. if isFollowingMe and isFollowingThem then -- mutual
  223. return FOLLOWER_STATUS.MUTUAL
  224. elseif isFollowingMe then
  225. return FOLLOWER_STATUS.FOLLOWER
  226. elseif isFollowingThem then
  227. return FOLLOWER_STATUS.FOLLOWING
  228. else
  229. return nil
  230. end
  231. end
  232.  
  233. local function getFriendStatusIcon(friendStatus)
  234. if friendStatus == Enum.FriendStatus.Unknown or friendStatus == Enum.FriendStatus.NotFriend then
  235. return nil
  236. elseif friendStatus == Enum.FriendStatus.Friend then
  237. return FRIEND_ICON
  238. elseif friendStatus == Enum.FriendStatus.FriendRequestSent then
  239. return FRIEND_REQUEST_ICON
  240. elseif friendStatus == Enum.FriendStatus.FriendRequestReceived then
  241. return FRIEND_RECEIVED_ICON
  242. else
  243. error("PlayerList: Unknown value for friendStatus: "..tostring(friendStatus))
  244. end
  245. end
  246.  
  247. local function getFollowerStatusIcon(followerStatus)
  248. if followerStatus == FOLLOWER_STATUS.MUTUAL then
  249. return MUTUAL_FOLLOWING_ICON
  250. elseif followerStatus == FOLLOWER_STATUS.FOLLOWING then
  251. return FOLLOWING_ICON
  252. elseif followerStatus == FOLLOWER_STATUS.FOLLOWER then
  253. return FOLLOWER_ICON
  254. else
  255. return nil
  256. end
  257. end
  258.  
  259. local function getAdminIcon(player)
  260. local userIdStr = tostring(player.userId)
  261. if ADMINS[userIdStr] then return nil end
  262. --
  263. local success, result = pcall(function()
  264. return player:IsInGroup(1200769) -- yields
  265. end)
  266. if not success then
  267. print("PlayerListScript2: getAdminIcon() failed because", result)
  268. end
  269. --
  270. if result then
  271. return ADMIN_ICON
  272. end
  273. end
  274.  
  275. local function getMembershipIcon(player)
  276. local userIdStr = tostring(player.userId)
  277. local membershipType = player.MembershipType
  278. if ADMINS[userIdStr] then
  279. return ADMINS[userIdStr]
  280. elseif ADMINS[userIdStr] then
  281. return ADMINS[userIdStr]
  282. elseif player.userId == game.CreatorId and game.CreatorType == Enum.CreatorType.User then
  283. return PLACE_OWNER_ICON
  284. elseif game.CreatorType == Enum.CreatorType.Group and player:GetRankInGroup(game.CreatorId) == 255 then
  285. return PLACE_OWNER_ICON
  286. elseif membershipType == Enum.MembershipType.None then
  287. return nil
  288. elseif membershipType == Enum.MembershipType.BuildersClub then
  289. return BC_ICON
  290. elseif membershipType == Enum.MembershipType.TurboBuildersClub then
  291. return TBC_ICON
  292. elseif membershipType == Enum.MembershipType.OutrageousBuildersClub then
  293. return OBC_ICON
  294. else
  295. error("PlayerList: Unknown value for membershipType"..tostring(membershipType))
  296. end
  297. end
  298.  
  299. local function isValidStat(obj)
  300. return obj:IsA('StringValue') or obj:IsA('IntValue') or obj:IsA('BoolValue') or obj:IsA('NumberValue') or
  301. obj:IsA('DoubleConstrainedValue') or obj:IsA('IntConstrainedValue')
  302. end
  303.  
  304. local function sortPlayerEntries(a, b)
  305. if a.PrimaryStat == b.PrimaryStat then
  306. return a.Player.Name:upper() < b.Player.Name:upper()
  307. end
  308. if not a.PrimaryStat then return false end
  309. if not b.PrimaryStat then return true end
  310. return a.PrimaryStat > b.PrimaryStat
  311. end
  312.  
  313. local function sortLeaderStats(a, b)
  314. if a.IsPrimary ~= b.IsPrimary then
  315. return a.IsPrimary
  316. end
  317. if a.Priority == b.Priority then
  318. return a.AddId < b.AddId
  319. end
  320. return a.Priority < b.Priority
  321. end
  322.  
  323. local function sortTeams(a, b)
  324. if a.TeamScore == b.TeamScore then
  325. return a.Id < b.Id
  326. end
  327. if not a.TeamScore then return false end
  328. if not b.TeamScore then return true end
  329. return a.TeamScore < b.TeamScore
  330. end
  331.  
  332. local function sendNotification(title, text, image, duration, callback)
  333. if IsNewNotifications and BinbableFunction_SendNotification then
  334. BinbableFunction_SendNotification:Invoke(title, text, image, duration, callback)
  335. else
  336. GuiService:SendNotification(title, text, image, duration, callback)
  337. end
  338. end
  339.  
  340. -- Start of Gui Creation
  341. local Container = Instance.new('Frame')
  342. Container.Name = "PlayerListContainer"
  343. Container.Position = UDim2.new(1, -200, 0, 2)
  344. Container.Size = MinContainerSize
  345. Container.BackgroundTransparency = 1
  346. Container.Visible = false
  347. Container.Parent = RobloxGui
  348.  
  349. -- Scrolling Frame
  350. local ScrollList = Instance.new('ScrollingFrame')
  351. ScrollList.Name = "ScrollList"
  352. ScrollList.Size = UDim2.new(1, -1, 0, 0)
  353. ScrollList.BackgroundTransparency = 1
  354. ScrollList.BackgroundColor3 = Color3.new()
  355. ScrollList.BorderSizePixel = 0
  356. ScrollList.CanvasSize = UDim2.new(0, 0, 0, 0) -- NOTE: Look into if x needs to be set to anything
  357. ScrollList.ScrollBarThickness = 6
  358. ScrollList.BottomImage = 'rbxasset://textures/ui/scroll-bottom.png'
  359. ScrollList.MidImage = 'rbxasset://textures/ui/scroll-middle.png'
  360. ScrollList.TopImage = 'rbxasset://textures/ui/scroll-top.png'
  361. ScrollList.Parent = Container
  362.  
  363. -- Friend/Report Popup
  364. local PopupFrame = nil
  365. local PopupClipFrame = Instance.new('Frame')
  366. PopupClipFrame.Name = "PopupClipFrame"
  367. PopupClipFrame.Size = UDim2.new(0, 150, 1, 0)
  368. PopupClipFrame.Position = UDim2.new(0, -151, 0, 2)
  369. PopupClipFrame.BackgroundTransparency = 1
  370. PopupClipFrame.ClipsDescendants = true
  371. PopupClipFrame.Parent = Container
  372.  
  373. -- Report Abuse Gui
  374. local ReportAbuseShield = Instance.new('TextButton')
  375. ReportAbuseShield.Name = "ReportAbuseShield"
  376. ReportAbuseShield.Size = UDim2.new(1, 0, 1, 0)
  377. ReportAbuseShield.Position = UDim2.new(0, 0, 0, 0)
  378. ReportAbuseShield.BackgroundColor3 = Color3.new(51/255, 51/255, 51/255)
  379. ReportAbuseShield.BackgroundTransparency = 0.4
  380. ReportAbuseShield.ZIndex = 1
  381. ReportAbuseShield.Text = ""
  382. ReportAbuseShield.AutoButtonColor = false
  383.  
  384. local ReportAbuseFrame = Instance.new('Frame')
  385. ReportAbuseFrame.Name = "ReportAbuseFrame"
  386. ReportAbuseFrame.Size = UDim2.new(0, 480, 0, 320)
  387. ReportAbuseFrame.Position = UDim2.new(0.5, -240, 0.5, -160)
  388. ReportAbuseFrame.BackgroundTransparency = 0.7
  389. ReportAbuseFrame.BackgroundColor3 = Color3.new(0, 0, 0)
  390. ReportAbuseFrame.Style = Enum.FrameStyle.DropShadow
  391. ReportAbuseFrame.Parent = ReportAbuseShield
  392.  
  393. local ReportAbuseDescription = Instance.new('TextLabel')
  394. ReportAbuseDescription.Name = "ReportAbuseDescription"
  395. ReportAbuseDescription.Text = "This will send a complete report to a moderator. The moderator will review the chat log and take appropriate action."
  396. ReportAbuseDescription.Size = UDim2.new(1, -20, 0, 40)
  397. ReportAbuseDescription.Position = UDim2.new(0, 10, 0, 10)
  398. ReportAbuseDescription.BackgroundTransparency = 1
  399. ReportAbuseDescription.Font = Enum.Font.SourceSans
  400. ReportAbuseDescription.FontSize = Enum.FontSize.Size18
  401. ReportAbuseDescription.TextColor3 = Color3.new(1, 1, 1)
  402. ReportAbuseDescription.TextWrap = true
  403. ReportAbuseDescription.TextXAlignment = Enum.TextXAlignment.Left
  404. ReportAbuseDescription.TextYAlignment = Enum.TextYAlignment.Top
  405. ReportAbuseDescription.Parent = ReportAbuseFrame
  406.  
  407. local ReportPlayerLabel = Instance.new('TextLabel')
  408. ReportPlayerLabel.Name = "ReportPlayerLabel"
  409. ReportPlayerLabel.Text = "Player Reporting:"
  410. ReportPlayerLabel.Size = UDim2.new(0.4, 0, 0, 36)
  411. ReportPlayerLabel.Position = UDim2.new(0.025, 20, 0, 80)
  412. ReportPlayerLabel.BackgroundTransparency = 1
  413. ReportPlayerLabel.Font = Enum.Font.SourceSans
  414. ReportPlayerLabel.FontSize = Enum.FontSize.Size18
  415. ReportPlayerLabel.TextColor3 = Color3.new(1, 1, 1)
  416. ReportPlayerLabel.TextXAlignment = Enum.TextXAlignment.Left
  417. ReportPlayerLabel.Parent = ReportAbuseFrame
  418.  
  419. local ReportPlayerName = Instance.new('TextLabel')
  420. ReportPlayerName.Name = "ReportPlayerName"
  421. ReportPlayerName.Text = ""
  422. ReportPlayerName.Size = UDim2.new(0.95, 0, 0, 36)
  423. ReportPlayerName.Position = UDim2.new(0.025, 0, 0, 80)
  424. ReportPlayerName.BackgroundTransparency = 1
  425. ReportPlayerName.Font = Enum.Font.SourceSans
  426. ReportPlayerName.FontSize = Enum.FontSize.Size18
  427. ReportPlayerName.TextColor3 = Color3.new(1, 1, 1)
  428. ReportPlayerName.TextXAlignment = Enum.TextXAlignment.Right
  429. ReportPlayerName.Parent = ReportAbuseFrame
  430.  
  431. local ReportReasonLabel = Instance.new('TextLabel')
  432. ReportReasonLabel.Name = "ReportReasonLabel"
  433. ReportReasonLabel.Text = "Type of Abuse:"
  434. ReportReasonLabel.Size = UDim2.new(0.4, 0, 0, 36)
  435. ReportReasonLabel.Position = UDim2.new(0.025, 20, 0, 119)
  436. ReportReasonLabel.BackgroundTransparency = 1
  437. ReportReasonLabel.Font = Enum.Font.SourceSans
  438. ReportReasonLabel.FontSize = Enum.FontSize.Size18
  439. ReportReasonLabel.TextColor3 = Color3.new(1, 1, 1)
  440. ReportReasonLabel.TextXAlignment = Enum.TextXAlignment.Left
  441. ReportReasonLabel.Parent = ReportAbuseFrame
  442.  
  443. local ReportDescriptionLabel = Instance.new('TextLabel')
  444. ReportDescriptionLabel.Name = "ReportDescriptionLabel"
  445. ReportDescriptionLabel.Text = "Short Description: (optional)"
  446. ReportDescriptionLabel.Size = UDim2.new(0.95, 0, 0, 36)
  447. ReportDescriptionLabel.Position = UDim2.new(0.025, 0, 0, 165)
  448. ReportDescriptionLabel.BackgroundTransparency = 1
  449. ReportDescriptionLabel.Font = Enum.Font.SourceSans
  450. ReportDescriptionLabel.FontSize = Enum.FontSize.Size18
  451. ReportDescriptionLabel.TextColor3 = Color3.new(1, 1, 1)
  452. ReportDescriptionLabel.TextXAlignment = Enum.TextXAlignment.Left
  453. ReportDescriptionLabel.Parent = ReportAbuseFrame
  454.  
  455. local ReportSubmitButton = Instance.new('TextButton')
  456. ReportSubmitButton.Name = "ReportSubmitButton"
  457. ReportSubmitButton.Text = "Submit Report"
  458. ReportSubmitButton.Size = UDim2.new(0.35, 0, 0, 40)
  459. ReportSubmitButton.Position = UDim2.new(0.1, 0, 1, -50)
  460. ReportSubmitButton.Font = Enum.Font.SourceSans
  461. ReportSubmitButton.FontSize = Enum.FontSize.Size18
  462. ReportSubmitButton.TextColor3 = Color3.new(163/255, 162/255, 165/255)
  463. ReportSubmitButton.Active = false
  464. ReportSubmitButton.AutoButtonColor = true
  465. ReportSubmitButton.Modal = true
  466. ReportSubmitButton.Style = Enum.ButtonStyle.RobloxRoundDefaultButton
  467. ReportSubmitButton.Parent = ReportAbuseFrame
  468.  
  469. local ReportCanelButton = Instance.new('TextButton')
  470. ReportCanelButton.Name = "ReportCanelButton"
  471. ReportCanelButton.Text = "Cancel"
  472. ReportCanelButton.Size = UDim2.new(0.35, 0, 0, 40)
  473. ReportCanelButton.Position = UDim2.new(0.55, 0, 1, -50)
  474. ReportCanelButton.Font = Enum.Font.SourceSans
  475. ReportCanelButton.FontSize = Enum.FontSize.Size18
  476. ReportCanelButton.TextColor3 = Color3.new(1, 1, 1)
  477. ReportCanelButton.Style = Enum.ButtonStyle.RobloxRoundDefaultButton
  478. ReportCanelButton.Parent = ReportAbuseFrame
  479.  
  480. local AbuseDropDown, updateAbuseSelection = nil, nil
  481. if IsNewSettings then
  482. AbuseDropDown = RbxGuiLibrary.CreateScrollingDropDownMenu(
  483. function(text)
  484. AbuseReason = text
  485. if AbuseReason and AbusingPlayer then
  486. ReportSubmitButton.Active = true
  487. ReportSubmitButton.TextColor3 = Color3.new(1, 1, 1)
  488. end
  489. end, UDim2.new(0.55, 0, 0, 32), UDim2.new(0.425, 0, 0, 121), 1)
  490. AbuseDropDown.CreateList(ABUSES)
  491. AbuseDropDown.Frame.Parent = ReportAbuseFrame
  492. else
  493. AbuseDropDown, updateAbuseSelection = RbxGuiLibrary.CreateDropDownMenu(ABUSES,
  494. function(abuseText)
  495. AbuseReason = abuseText
  496. if AbuseReason and AbusingPlayer then
  497. ReportSubmitButton.Active = true
  498. ReportSubmitButton.TextColor3 = Color3.new(1, 1, 1)
  499. end
  500. end, true, true, 1)
  501. AbuseDropDown.Name = "AbuseDropDown"
  502. AbuseDropDown.Size = UDim2.new(0.55, 0, 0, 32)
  503. AbuseDropDown.Position = UDim2.new(0.425, 0, 0, 121)
  504. AbuseDropDown.Parent = ReportAbuseFrame
  505. end
  506.  
  507. local ReportDescriptionTextFrame = Instance.new('Frame')
  508. ReportDescriptionTextFrame.Name = "ReportDescriptionTextFrame"
  509. ReportDescriptionTextFrame.Size = UDim2.new(0.95, 0, 1, -250)
  510. ReportDescriptionTextFrame.Position = UDim2.new(0.025, 0, 0, 195)
  511. ReportDescriptionTextFrame.BackgroundColor3 = Color3.new(206/255, 206/255, 206/255)
  512. ReportDescriptionTextFrame.BorderSizePixel = 0
  513. ReportDescriptionTextFrame.Parent = ReportAbuseFrame
  514.  
  515. local ReportDescriptionBox = Instance.new('TextBox')
  516. ReportDescriptionBox.Name = "ReportDescriptionBox"
  517. ReportDescriptionBox.Text = ""
  518. ReportDescriptionBox.Size = UDim2.new(1, -6, 1, -6)
  519. ReportDescriptionBox.Position = UDim2.new(0, 3, 0, 3)
  520. ReportDescriptionBox.Font = Enum.Font.SourceSans
  521. ReportDescriptionBox.FontSize = Enum.FontSize.Size18
  522. ReportDescriptionBox.TextColor3 = Color3.new(0, 0, 0)
  523. ReportDescriptionBox.BackgroundColor3 = Color3.new(206/255, 206/255, 206/255)
  524. ReportDescriptionBox.BorderColor3 = Color3.new(206/255, 206/255, 206/255)
  525. ReportDescriptionBox.TextXAlignment = Enum.TextXAlignment.Left
  526. ReportDescriptionBox.TextYAlignment = Enum.TextYAlignment.Top
  527. ReportDescriptionBox.TextWrap = true
  528. ReportDescriptionBox.ClearTextOnFocus = false
  529. ReportDescriptionBox.Parent = ReportDescriptionTextFrame
  530.  
  531. -- Report Confirm Gui
  532. local ReportConfirmFrame = Instance.new('Frame')
  533. ReportConfirmFrame.Name = "ReportConfirmFrame"
  534. ReportConfirmFrame.Size = UDim2.new(0, 400, 0, 160)
  535. ReportConfirmFrame.Position = UDim2.new(0.5, -200, 0.5, -80)
  536. ReportConfirmFrame.BackgroundTransparency = 0.7
  537. ReportConfirmFrame.BackgroundColor3 = Color3.new(0, 0, 0)
  538. ReportConfirmFrame.Style = Enum.FrameStyle.DropShadow
  539.  
  540. local ReportConfirmHeader = Instance.new('TextLabel')
  541. ReportConfirmHeader.Name = "ReportConfirmHeader"
  542. ReportConfirmHeader.Size = UDim2.new(0, 0, 0, 0)
  543. ReportConfirmHeader.Position = UDim2.new(0.5, 0, 0, 14)
  544. ReportConfirmHeader.BackgroundTransparency = 1
  545. ReportConfirmHeader.Text = "Thank You For Your Report"
  546. ReportConfirmHeader.Font = Enum.Font.SourceSans
  547. ReportConfirmHeader.FontSize = Enum.FontSize.Size36
  548. ReportConfirmHeader.TextColor3 = Color3.new(1, 1, 1)
  549. ReportConfirmHeader.Parent = ReportConfirmFrame
  550.  
  551. local ReportConfirmText = Instance.new('TextLabel')
  552. ReportConfirmText.Name = "ReportConfirmText"
  553. ReportConfirmText.Text = "Our moderators will review your report and the chat log to determine what happened."
  554. ReportConfirmText.Size = UDim2.new(1, -20, 0, 40)
  555. ReportConfirmText.Position = UDim2.new(0, 10, 0, 46)
  556. ReportConfirmText.BackgroundTransparency = 1
  557. ReportConfirmText.Font = Enum.Font.SourceSans
  558. ReportConfirmText.FontSize = Enum.FontSize.Size18
  559. ReportConfirmText.TextColor3 = Color3.new(1, 1, 1)
  560. ReportConfirmText.TextWrap = true
  561. ReportConfirmText.TextXAlignment = Enum.TextXAlignment.Left
  562. ReportConfirmText.TextYAlignment = Enum.TextYAlignment.Top
  563. ReportConfirmText.Parent = ReportConfirmFrame
  564.  
  565. local ReportConfirmButton = Instance.new('TextButton')
  566. ReportConfirmButton.Name = "ReportConfirmButton"
  567. ReportConfirmButton.Text = "OK"
  568. ReportConfirmButton.Size = UDim2.new(0, 162, 0, 40)
  569. ReportConfirmButton.Position = UDim2.new(0.5, -81, 1, -50)
  570. ReportConfirmButton.Font = Enum.Font.SourceSans
  571. ReportConfirmButton.FontSize = Enum.FontSize.Size18
  572. ReportConfirmButton.TextColor3 = Color3.new(1, 1, 1)
  573. ReportConfirmButton.Style = Enum.ButtonStyle.RobloxRoundDefaultButton
  574. ReportConfirmButton.Parent = ReportConfirmFrame
  575.  
  576. local function onReportConfirmPressed()
  577. ReportConfirmFrame.Parent = nil
  578. ReportAbuseShield.Parent = nil
  579. ReportAbuseFrame.Parent = ReportAbuseShield
  580. end
  581. ReportConfirmButton.MouseButton1Click:connect(onReportConfirmPressed)
  582.  
  583. --[[ Creation Helper Functions ]]--
  584. local function createEntryFrame(name, sizeYOffset)
  585. local containerFrame = Instance.new('Frame')
  586. containerFrame.Name = name
  587. containerFrame.Position = UDim2.new(0, 0, 0, 0)
  588. containerFrame.Size = UDim2.new(1, 0, 0, sizeYOffset)
  589. containerFrame.BackgroundTransparency = 1
  590.  
  591. local nameFrame = Instance.new('TextButton')
  592. nameFrame.Name = "BGFrame"
  593. nameFrame.Position = UDim2.new(0, 0, 0, 0)
  594. nameFrame.Size = UDim2.new(0, NameEntrySizeX, 0, sizeYOffset)
  595. nameFrame.BackgroundTransparency = BG_TRANSPARENCY
  596. nameFrame.BackgroundColor3 = BG_COLOR
  597. nameFrame.BorderSizePixel = 0
  598. nameFrame.ClipsDescendants = true
  599. nameFrame.AutoButtonColor = false
  600. nameFrame.Text = ""
  601. nameFrame.Parent = containerFrame
  602.  
  603. return containerFrame, nameFrame
  604. end
  605.  
  606. local function createEntryNameText(name, text, sizeXOffset, posXOffset)
  607. local nameLabel = Instance.new('TextLabel')
  608. nameLabel.Name = name
  609. nameLabel.Size = UDim2.new(-0.01, sizeXOffset, 0.5, 0)
  610. nameLabel.Position = UDim2.new(0.01, posXOffset, 0.245, 0)
  611. nameLabel.BackgroundTransparency = 1
  612. nameLabel.Font = Enum.Font.SourceSans
  613. nameLabel.FontSize = Enum.FontSize.Size14
  614. nameLabel.TextColor3 = TEXT_COLOR
  615. nameLabel.TextStrokeTransparency = TEXT_STROKE_TRANSPARENCY
  616. nameLabel.TextStrokeColor3 = TEXT_STROKE_COLOR
  617. nameLabel.TextXAlignment = Enum.TextXAlignment.Left
  618. nameLabel.Text = text
  619.  
  620. return nameLabel
  621. end
  622.  
  623. local function createStatFrame(offset, parent, name)
  624. local statFrame = Instance.new('Frame')
  625. statFrame.Name = name
  626. statFrame.Size = UDim2.new(0, StatEntrySizeX, 1, 0)
  627. statFrame.Position = UDim2.new(0, offset + 1, 0, 0)
  628. statFrame.BackgroundTransparency = BG_TRANSPARENCY
  629. statFrame.BackgroundColor3 = BG_COLOR
  630. statFrame.BorderSizePixel = 0
  631. statFrame.Parent = parent
  632.  
  633. return statFrame
  634. end
  635.  
  636. local function createStatText(parent, text)
  637. local statText = Instance.new('TextLabel')
  638. statText.Name = "StatText"
  639. statText.Size = UDim2.new(1, 0, 1, 0)
  640. statText.Position = UDim2.new(0, 0, 0, 0)
  641. statText.BackgroundTransparency = 1
  642. statText.Font = Enum.Font.SourceSans
  643. statText.FontSize = Enum.FontSize.Size14
  644. statText.TextColor3 = TEXT_COLOR
  645. statText.TextStrokeColor3 = TEXT_STROKE_COLOR
  646. statText.TextStrokeTransparency = TEXT_STROKE_TRANSPARENCY
  647. statText.Text = text
  648. statText.Active = true
  649. statText.Parent = parent
  650.  
  651. return statText
  652. end
  653.  
  654. local function createImageIcon(image, name, xOffset, parent)
  655. local imageLabel = Instance.new('ImageLabel')
  656. imageLabel.Name = name
  657. imageLabel.Size = UDim2.new(0, 16, 0, 16)
  658. imageLabel.Position = UDim2.new(0.01, xOffset, 0.5, -imageLabel.Size.Y.Offset/2)
  659. imageLabel.BackgroundTransparency = 1
  660. imageLabel.Image = image
  661. imageLabel.BorderSizePixel = 0
  662. imageLabel.Parent = parent
  663.  
  664. return imageLabel
  665. end
  666.  
  667. local function getScoreValue(statObject)
  668. if statObject:IsA('DoubleConstrainedValue') or statObject:IsA('IntConstrainedValue') then
  669. return statObject.ConstrainedValue
  670. elseif statObject:IsA('BoolValue') then
  671. if statObject.Value then return 1 else return 0 end
  672. else
  673. return statObject.Value
  674. end
  675. end
  676.  
  677. local THIN_CHARS = "[^%[iIl\%.,']"
  678. local function strWidth(str)
  679. return string.len(str) - math.floor(string.len(string.gsub(str, THIN_CHARS, "")) / 2)
  680. end
  681.  
  682. local function formatNumber(value)
  683. local _,_,minusSign, int, fraction = tostring(value):find('([-]?)(%d+)([.]?%d*)')
  684. int = int:reverse():gsub("%d%d%d", "%1,")
  685. return minusSign..int:reverse():gsub("^,", "")..fraction
  686. end
  687.  
  688. local function formatStatString(text)
  689. local numberValue = tonumber(text)
  690. if numberValue then
  691. text = formatNumber(numberValue)
  692. end
  693.  
  694. if strWidth(text) <= MAX_STR_LEN then
  695. return text
  696. else
  697. return string.sub(text, 1, MAX_STR_LEN - 3).."..."
  698. end
  699. end
  700.  
  701. --[[ Resize Functions ]]--
  702. local LastMaxScrollSize = 0
  703. local function setScrollListSize()
  704. local teamSize = #TeamEntries * TeamEntrySizeY
  705. local playerSize = #PlayerEntries * PlayerEntrySizeY
  706. local spacing = #PlayerEntries * ENTRY_PAD + #TeamEntries * ENTRY_PAD
  707. local canvasSize = teamSize + playerSize + spacing
  708. if #TeamEntries > 0 and NeutralTeam and IsShowingNeutralFrame then
  709. canvasSize = canvasSize + TeamEntrySizeY + ENTRY_PAD
  710. end
  711. ScrollList.CanvasSize = UDim2.new(0, 0, 0, canvasSize)
  712. local newScrollListSize = math.min(canvasSize, Container.AbsoluteSize.y)
  713. if ScrollList.Size.Y.Offset == LastMaxScrollSize then
  714. ScrollList.Size = UDim2.new(1, 0, 0, newScrollListSize)
  715. end
  716. LastMaxScrollSize = newScrollListSize
  717. end
  718.  
  719. --[[ Re-position Functions ]]--
  720. local function setPlayerEntryPositions()
  721. local position = 0
  722. for i = 1, #PlayerEntries do
  723. PlayerEntries[i].Frame.Position = UDim2.new(0, 0, 0, position)
  724. position = position + PlayerEntrySizeY + 2
  725. end
  726. end
  727.  
  728. local function setTeamEntryPositions()
  729. local teams = {}
  730. for _,teamEntry in ipairs(TeamEntries) do
  731. local team = teamEntry.Team
  732. teams[tostring(team.TeamColor)] = {}
  733. end
  734. if NeutralTeam then
  735. teams.Neutral = {}
  736. end
  737.  
  738. for _,playerEntry in ipairs(PlayerEntries) do
  739. local player = playerEntry.Player
  740. if player.Neutral then
  741. table.insert(teams.Neutral, playerEntry)
  742. elseif teams[tostring(player.TeamColor)] then
  743. table.insert(teams[tostring(player.TeamColor)], playerEntry)
  744. else
  745. table.insert(teams.Neutral, playerEntry)
  746. end
  747. end
  748.  
  749. local position = 0
  750. for _,teamEntry in ipairs(TeamEntries) do
  751. local team = teamEntry.Team
  752. teamEntry.Frame.Position = UDim2.new(0, 0, 0, position)
  753. position = position + TeamEntrySizeY + 2
  754. local players = teams[tostring(team.TeamColor)]
  755. for _,playerEntry in ipairs(players) do
  756. playerEntry.Frame.Position = UDim2.new(0, 0, 0, position)
  757. position = position + PlayerEntrySizeY + 2
  758. end
  759. end
  760. if NeutralTeam then
  761. NeutralTeam.Frame.Position = UDim2.new(0, 0, 0, position)
  762. position = position + TeamEntrySizeY + 2
  763. if #teams.Neutral > 0 then
  764. IsShowingNeutralFrame = true
  765. local players = teams.Neutral
  766. for _,playerEntry in ipairs(players) do
  767. playerEntry.Frame.Position = UDim2.new(0, 0, 0, position)
  768. position = position + PlayerEntrySizeY + 2
  769. end
  770. else
  771. IsShowingNeutralFrame = false
  772. end
  773. end
  774. end
  775.  
  776. local function setEntryPositions()
  777. table.sort(PlayerEntries, sortPlayerEntries)
  778. if #TeamEntries > 0 then
  779. setTeamEntryPositions()
  780. else
  781. setPlayerEntryPositions()
  782. end
  783. end
  784.  
  785. --[[ Friend/Report Functions ]]--
  786. local selectedEntryMovedCn = nil
  787. local function createPopupFrame(buttons)
  788. local frame = Instance.new('Frame')
  789. frame.Name = "PopupFrame"
  790. frame.Size = UDim2.new(1, 0, 0, (PlayerEntrySizeY * #buttons) + (#buttons - 1))
  791. frame.Position = UDim2.new(1, 1, 0, 0)
  792. frame.BackgroundTransparency = 1
  793. frame.Parent = PopupClipFrame
  794.  
  795. for i,button in ipairs(buttons) do
  796. local btn = Instance.new('TextButton')
  797. btn.Name = button.Name
  798. btn.Size = UDim2.new(1, 0, 0, PlayerEntrySizeY)
  799. btn.Position = UDim2.new(0, 0, 0, PlayerEntrySizeY * (i - 1) + (i - 1))
  800. btn.BackgroundTransparency = BG_TRANSPARENCY
  801. btn.BackgroundColor3 = BG_COLOR
  802. btn.BorderSizePixel = 0
  803. btn.Text = button.Text
  804. btn.Font = Enum.Font.SourceSans
  805. btn.FontSize = Enum.FontSize.Size14
  806. btn.TextColor3 = TEXT_COLOR
  807. btn.TextStrokeTransparency = TEXT_STROKE_TRANSPARENCY
  808. btn.TextStrokeColor3 = TEXT_STROKE_COLOR
  809. btn.AutoButtonColor = true
  810. btn.Parent = frame
  811.  
  812. btn.MouseButton1Click:connect(button.OnPress)
  813. end
  814.  
  815. return frame
  816. end
  817.  
  818. -- if userId = nil, then it will get count for local player
  819. local function getFriendCount(userId)
  820. local friendCount = nil
  821. local wasSuccess, result = pcall(function()
  822. local str = 'user/get-friendship-count'
  823. if userId then
  824. str = str..'?userId='..tostring(userId)
  825. end
  826. return HttpRbxApiService:GetAsync(str, true)
  827. end)
  828. if not wasSuccess then
  829. print("getFriendCount() failed because", result)
  830. return nil
  831. end
  832. result = HttpService:JSONDecode(result)
  833.  
  834. if result["success"] and result["count"] then
  835. friendCount = result["count"]
  836. end
  837.  
  838. return friendCount
  839. end
  840.  
  841. -- checks if we can send a friend request. Right now the only way we
  842. -- can't is if one of the players is at the max friend limit
  843. local function canSendFriendRequest(otherPlayer)
  844. if not IsMaxFriendsCount then return true end
  845. --
  846. local myFriendCount = getFriendCount()
  847. local theirFriendCount = getFriendCount(otherPlayer.userId)
  848.  
  849. -- assume max friends if web call fails
  850. if not myFriendCount or not theirFriendCount then
  851. return false
  852. end
  853. if myFriendCount < MAX_FRIEND_COUNT and theirFriendCount < MAX_FRIEND_COUNT then
  854. return true
  855. elseif myFriendCount >= MAX_FRIEND_COUNT then
  856. sendNotification("Cannot send friend request", "You are at the max friends limit.", "", 5, function() end)
  857. return false
  858. elseif theirFriendCount >= MAX_FRIEND_COUNT then
  859. sendNotification("Cannot send friend request", otherPlayer.Name.." is at the max friends limit.", "", 5, function() end)
  860. return false
  861. end
  862. end
  863.  
  864. local function hideFriendReportPopup()
  865. if PopupFrame then
  866. PopupFrame:TweenPosition(UDim2.new(1, 1, 0, PopupFrame.Position.Y.Offset), Enum.EasingDirection.InOut,
  867. Enum.EasingStyle.Quad, TWEEN_TIME, true, function()
  868. PopupFrame:Destroy()
  869. PopupFrame = nil
  870. if selectedEntryMovedCn then
  871. selectedEntryMovedCn:disconnect()
  872. selectedEntryMovedCn = nil
  873. end
  874. end)
  875. end
  876. if LastSelectedFrame then
  877. for _,childFrame in pairs(LastSelectedFrame:GetChildren()) do
  878. if childFrame:IsA('TextButton') or childFrame:IsA('Frame') then
  879. childFrame.BackgroundColor3 = BG_COLOR
  880. end
  881. end
  882. end
  883. ScrollList.ScrollingEnabled = true
  884. LastSelectedFrame = nil
  885. LastSelectedPlayer = nil
  886. end
  887.  
  888. local function updateSocialIcon(newIcon, bgFrame)
  889. local socialIcon = bgFrame:FindFirstChild('SocialIcon')
  890. local nameFrame = bgFrame:FindFirstChild('PlayerName')
  891. local offset = 19
  892. if socialIcon then
  893. if newIcon then
  894. socialIcon.Image = newIcon
  895. else
  896. if nameFrame then
  897. newSize = nameFrame.Size.X.Offset + socialIcon.Size.X.Offset + 2
  898. nameFrame.Size = UDim2.new(-0.01, newSize, 0.5, 0)
  899. nameFrame.Position = UDim2.new(0.01, offset, 0.245, 0)
  900. end
  901. socialIcon:Destroy()
  902. end
  903. elseif newIcon and bgFrame then
  904. socialIcon = createImageIcon(newIcon, "SocialIcon", offset, bgFrame)
  905. offset = offset + socialIcon.Size.X.Offset + 2
  906. if nameFrame then
  907. local newSize = bgFrame.Size.X.Offset - offset
  908. nameFrame.Size = UDim2.new(-0.01, newSize, 0.5, 0)
  909. nameFrame.Position = UDim2.new(0.01, offset, 0.245, 0)
  910. end
  911. end
  912. end
  913.  
  914. local function onFollowerStatusChanged()
  915. if not LastSelectedFrame or not LastSelectedPlayer then
  916. return
  917. end
  918.  
  919. -- don't update icon if already friends
  920. local friendStatus = getFriendStatus(LastSelectedPlayer)
  921. if friendStatus == Enum.FriendStatus.Friend then
  922. return
  923. end
  924.  
  925. local bgFrame = LastSelectedFrame:FindFirstChild('BGFrame')
  926. local followerStatus = getFollowerStatus(LastSelectedPlayer)
  927. local newIcon = getFollowerStatusIcon(followerStatus)
  928. if bgFrame then
  929. updateSocialIcon(newIcon, bgFrame)
  930. end
  931. end
  932.  
  933. -- Client follows followedUserId
  934. local function onFollowButtonPressed()
  935. if not LastSelectedPlayer then return end
  936. --
  937. local followedUserId = tostring(LastSelectedPlayer.userId)
  938. local apiPath = "user/follow"
  939. local params = "followedUserId="..followedUserId
  940. local success, result = pcall(function()
  941. return HttpRbxApiService:PostAsync(apiPath, params, true, Enum.ThrottlingPriority.Default, Enum.HttpContentType.ApplicationUrlEncoded)
  942. end)
  943. if not success then
  944. print("followPlayer() failed because", result)
  945. hideFriendReportPopup()
  946. return
  947. end
  948.  
  949. result = HttpService:JSONDecode(result)
  950. if result["success"] then
  951. sendNotification("You are", "now following "..LastSelectedPlayer.Name, FRIEND_IMAGE..followedUserId.."&x=48&y=48", 5, function() end)
  952. if IsServerCoreScripts and RemoteEvent_OnNewFollower then
  953. RemoteEvent_OnNewFollower:FireServer(Player, LastSelectedPlayer)
  954. end
  955. -- now update the social icon
  956. onFollowerStatusChanged()
  957. end
  958.  
  959. hideFriendReportPopup()
  960. end
  961.  
  962. -- TODO: Move this to the notifications script. For now I want to keep it here until the
  963. -- new notifications system goes live
  964. if IsServerCoreScripts and RemoteEvent_OnNewFollower then
  965. RemoteEvent_OnNewFollower.OnClientEvent:connect(function(followerRbxPlayer)
  966. sendNotification("New Follower", followerRbxPlayer.Name.."is now following you!",
  967. FRIEND_IMAGE..followerRbxPlayer.userId.."&x=48&y=48", 5, function() end)
  968. end)
  969. end
  970.  
  971. -- Client unfollows followedUserId
  972. local function onUnfollowButtonPressed()
  973. if not LastSelectedPlayer then return end
  974. --
  975. local apiPath = "user/unfollow"
  976. local params = "followedUserId="..tostring(LastSelectedPlayer.userId)
  977. local success, result = pcall(function()
  978. return HttpRbxApiService:PostAsync(apiPath, params, true, Enum.ThrottlingPriority.Default, Enum.HttpContentType.ApplicationUrlEncoded)
  979. end)
  980. if not success then
  981. print("unfollowPlayer() failed because", result)
  982. hideFriendReportPopup()
  983. return
  984. end
  985.  
  986. result = HttpService:JSONDecode(result)
  987. if result["success"] then
  988. onFollowerStatusChanged()
  989. end
  990.  
  991. hideFriendReportPopup()
  992. -- no need to send notification when someone unfollows
  993. end
  994.  
  995. local function onFriendButtonPressed()
  996. if LastSelectedPlayer then
  997. local status = getFriendStatus(LastSelectedPlayer)
  998. if status == Enum.FriendStatus.Friend then
  999. Player:RevokeFriendship(LastSelectedPlayer)
  1000. elseif status == Enum.FriendStatus.Unknown or status == Enum.FriendStatus.NotFriend then
  1001. -- check for max friends before letting them send the request
  1002. if canSendFriendRequest(LastSelectedPlayer) then
  1003. Player:RequestFriendship(LastSelectedPlayer)
  1004. end
  1005. elseif status == Enum.FriendStatus.FriendRequestSent then
  1006. Player:RevokeFriendship(LastSelectedPlayer)
  1007. elseif status == Enum.FriendStatus.FriendRequestReceived then
  1008. Player:RequestFriendship(LastSelectedPlayer)
  1009. end
  1010.  
  1011. hideFriendReportPopup()
  1012. end
  1013. end
  1014.  
  1015. local function onReportButtonPressed()
  1016. if LastSelectedPlayer then
  1017. AbusingPlayer = LastSelectedPlayer
  1018. ReportPlayerName.Text = AbusingPlayer.Name
  1019. ReportAbuseShield.Parent = RobloxGui
  1020. hideFriendReportPopup()
  1021. end
  1022. end
  1023.  
  1024. local function resetReportDialog()
  1025. AbuseReason = nil
  1026. AbusingPlayer = nil
  1027. if IsNewSettings then -- FFlag
  1028. AbuseDropDown.SetSelectionText("Choose One")
  1029. else
  1030. updateAbuseSelection(nil)
  1031. end
  1032. ReportPlayerName.Text = ""
  1033. ReportDescriptionBox.Text = ""
  1034. ReportSubmitButton.Active = false
  1035. ReportSubmitButton.TextColor3 = Color3.new(163/255, 162/255, 165/255)
  1036. end
  1037.  
  1038. local function onAbuseDialogCanceled()
  1039. ReportAbuseShield.Parent = nil
  1040. resetReportDialog()
  1041. end
  1042. ReportCanelButton.MouseButton1Click:connect(onAbuseDialogCanceled)
  1043.  
  1044. local function onAbuseDialogSubmit()
  1045. if ReportSubmitButton.Active then
  1046. if AbuseReason and AbusingPlayer then
  1047. Players:ReportAbuse(AbusingPlayer, AbuseReason, ReportDescriptionBox.Text)
  1048. resetReportDialog()
  1049. ReportAbuseFrame.Parent = nil
  1050. ReportConfirmFrame.Parent = ReportAbuseShield
  1051. end
  1052. end
  1053. end
  1054. ReportSubmitButton.MouseButton1Click:connect(onAbuseDialogSubmit)
  1055.  
  1056. local function onDeclineFriendButonPressed()
  1057. if LastSelectedPlayer then
  1058. Player:RevokeFriendship(LastSelectedPlayer)
  1059. hideFriendReportPopup()
  1060. end
  1061. end
  1062.  
  1063. local function onPrivilegeLevelSelect(player, rank)
  1064. while player.PersonalServerRank < rank do
  1065. PersonalServerService:Promote(player)
  1066. end
  1067. while player.PersonalServerRank > rank do
  1068. PersonalServerService:Demote(player)
  1069. end
  1070. end
  1071.  
  1072. local function createPersonalServerDialog(buttons, selectedPlayer)
  1073. local showPersonalServerRanks = IsPersonalServer and Player.PersonalServerRank >= PRIVILEGE_LEVEL.ADMIN and
  1074. Player.PersonalServerRank > selectedPlayer.PersonalServerRank
  1075. if showPersonalServerRanks then
  1076. table.insert(buttons, {
  1077. Name = "BanButton",
  1078. Text = "Ban",
  1079. OnPress = function()
  1080. hideFriendReportPopup()
  1081. onPrivilegeLevelSelect(selectedPlayer, PRIVILEGE_LEVEL.BANNED)
  1082. end,
  1083. })
  1084. table.insert(buttons, {
  1085. Name = "VistorButton",
  1086. Text = "Visitor",
  1087. OnPress = function()
  1088. onPrivilegeLevelSelect(selectedPlayer, PRIVILEGE_LEVEL.VISITOR)
  1089. end,
  1090. })
  1091. table.insert(buttons, {
  1092. Name = "MemberButton",
  1093. Text = "Member",
  1094. OnPress = function()
  1095. onPrivilegeLevelSelect(selectedPlayer, PRIVILEGE_LEVEL.MEMBER)
  1096. end,
  1097. })
  1098. table.insert(buttons, {
  1099. Name = "AdminButton",
  1100. Text = "Admin",
  1101. OnPress = function()
  1102. onPrivilegeLevelSelect(selectedPlayer, PRIVILEGE_LEVEL.ADMIN)
  1103. end,
  1104. })
  1105. end
  1106. end
  1107.  
  1108. local function showFriendReportPopup(selectedFrame, selectedPlayer)
  1109. local buttons = {}
  1110.  
  1111. local status = getFriendStatus(selectedPlayer)
  1112. local friendText = ""
  1113. local canDeclineFriend = false
  1114. if status == Enum.FriendStatus.Friend then
  1115. friendText = "Unfriend Player"
  1116. elseif status == Enum.FriendStatus.Unknown or status == Enum.FriendStatus.NotFriend then
  1117. friendText = "Send Friend Request"
  1118. elseif status == Enum.FriendStatus.FriendRequestSent then
  1119. friendText = "Revoke Friend Request"
  1120. elseif status == Enum.FriendStatus.FriendRequestReceived then
  1121. friendText = "Accept Friend Request"
  1122. canDeclineFriend = true
  1123. end
  1124.  
  1125. table.insert(buttons, {
  1126. Name = "FriendButton",
  1127. Text = friendText,
  1128. OnPress = onFriendButtonPressed,
  1129. })
  1130. if canDeclineFriend then
  1131. table.insert(buttons, {
  1132. Name = "DeclineFriend",
  1133. Text = "Decline Friend Request",
  1134. OnPress = onDeclineFriendButonPressed,
  1135. })
  1136. end
  1137. -- following status
  1138. if IsFollowersEnabled then -- FFlag
  1139. local following = isFollowing(selectedPlayer.userId, Player.userId)
  1140. local followerText = following and "Unfollow Player" or "Follow Player"
  1141. table.insert(buttons, {
  1142. Name = "FollowerButton",
  1143. Text = followerText,
  1144. OnPress = following and onUnfollowButtonPressed or onFollowButtonPressed,
  1145. })
  1146. end
  1147. table.insert(buttons, {
  1148. Name = "ReportButton",
  1149. Text = "Report Abuse",
  1150. OnPress = onReportButtonPressed,
  1151. })
  1152.  
  1153. createPersonalServerDialog(buttons, selectedPlayer)
  1154. if PopupFrame then
  1155. PopupFrame:Destroy()
  1156. if selectedEntryMovedCn then
  1157. selectedEntryMovedCn:disconnect()
  1158. selectedEntryMovedCn = nil
  1159. end
  1160. end
  1161. PopupFrame = createPopupFrame(buttons)
  1162. PopupFrame.Position = UDim2.new(1, 1, 0, selectedFrame.Position.Y.Offset - ScrollList.CanvasPosition.y)
  1163. PopupFrame:TweenPosition(UDim2.new(0, 0, 0, selectedFrame.Position.Y.Offset - ScrollList.CanvasPosition.y), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, TWEEN_TIME, true)
  1164. selectedEntryMovedCn = selectedFrame.Changed:connect(function(property)
  1165. if property == "Position" then
  1166. PopupFrame.Position = UDim2.new(0, 0, 0, selectedFrame.Position.Y.Offset - ScrollList.CanvasPosition.y)
  1167. end
  1168. end)
  1169. end
  1170.  
  1171. local function onEntryFrameSelected(selectedFrame, selectedPlayer)
  1172. if selectedPlayer ~= Player and selectedPlayer.userId > 1 and Player.userId > 1 then
  1173. if LastSelectedFrame ~= selectedFrame then
  1174. if LastSelectedFrame then
  1175. for _,childFrame in pairs(LastSelectedFrame:GetChildren()) do
  1176. if childFrame:IsA('TextButton') or childFrame:IsA('Frame') then
  1177. childFrame.BackgroundColor3 = BG_COLOR
  1178. end
  1179. end
  1180. end
  1181. LastSelectedFrame = selectedFrame
  1182. LastSelectedPlayer = selectedPlayer
  1183. for _,childFrame in pairs(selectedFrame:GetChildren()) do
  1184. if childFrame:IsA('TextButton') or childFrame:IsA('Frame') then
  1185. childFrame.BackgroundColor3 = Color3.new(0, 1, 1)
  1186. end
  1187. end
  1188. -- NOTE: Core script only
  1189. ScrollList.ScrollingEnabled = false
  1190. showFriendReportPopup(selectedFrame, selectedPlayer)
  1191. else
  1192. hideFriendReportPopup()
  1193. LastSelectedFrame = nil
  1194. LastSelectedPlayer = nil
  1195. end
  1196. end
  1197. end
  1198.  
  1199. local function onFriendshipChanged(otherPlayer, newFriendStatus)
  1200. local entryToUpdate = nil
  1201. for _,entry in ipairs(PlayerEntries) do
  1202. if entry.Player == otherPlayer then
  1203. entryToUpdate = entry
  1204. break
  1205. end
  1206. end
  1207. if not entryToUpdate then
  1208. return
  1209. end
  1210. local newIcon = getFriendStatusIcon(newFriendStatus)
  1211. local frame = entryToUpdate.Frame
  1212. local bgFrame = frame:FindFirstChild('BGFrame')
  1213. if bgFrame then
  1214. -- no longer friends, but might still be following
  1215. if IsFollowersEnabled and not newIcon then
  1216. local followerStatus = getFollowerStatus(otherPlayer)
  1217. newIcon = getFollowerStatusIcon(followerStatus)
  1218. end
  1219.  
  1220. updateSocialIcon(newIcon, bgFrame)
  1221. end
  1222. end
  1223.  
  1224. -- NOTE: Core script only
  1225. Player.FriendStatusChanged:connect(onFriendshipChanged)
  1226.  
  1227. local function updateAllTeamScores()
  1228. local teamScores = {}
  1229. for _,playerEntry in ipairs(PlayerEntries) do
  1230. local player = playerEntry.Player
  1231. local leaderstats = player:FindFirstChild('leaderstats')
  1232. local team = player.Neutral and 'Neutral' or tostring(player.TeamColor)
  1233. local isInValidColor = true
  1234. if team ~= 'Neutral' then
  1235. for _,teamEntry in ipairs(TeamEntries) do
  1236. local color = teamEntry.Team.TeamColor
  1237. if team == tostring(color) then
  1238. isInValidColor = false
  1239. break
  1240. end
  1241. end
  1242. end
  1243. if isInValidColor then
  1244. team = 'Neutral'
  1245. end
  1246. if not teamScores[team] then
  1247. teamScores[team] = {}
  1248. end
  1249. if leaderstats then
  1250. for _,stat in ipairs(GameStats) do
  1251. local statObject = leaderstats:FindFirstChild(stat.Name)
  1252. if statObject and not statObject:IsA('StringValue') then
  1253. if not teamScores[team][stat.Name] then
  1254. teamScores[team][stat.Name] = 0
  1255. end
  1256. teamScores[team][stat.Name] = teamScores[team][stat.Name] + getScoreValue(statObject)
  1257. end
  1258. end
  1259. end
  1260. end
  1261.  
  1262. for _,teamEntry in ipairs(TeamEntries) do
  1263. local team = teamEntry.Team
  1264. local frame = teamEntry.Frame
  1265. local color = tostring(team.TeamColor)
  1266. local stats = teamScores[color]
  1267. if stats then
  1268. for statName,statValue in pairs(stats) do
  1269. local statFrame = frame:FindFirstChild(statName)
  1270. if statFrame then
  1271. local statText = statFrame:FindFirstChild('StatText')
  1272. if statText then
  1273. statText.Text = formatStatString(tostring(statValue))
  1274. end
  1275. end
  1276. end
  1277. else
  1278. for _,childFrame in pairs(frame:GetChildren()) do
  1279. local statText = childFrame:FindFirstChild('StatText')
  1280. if statText then
  1281. statText.Text = ''
  1282. end
  1283. end
  1284. end
  1285. end
  1286. if NeutralTeam then
  1287. local frame = NeutralTeam.Frame
  1288. local stats = teamScores['Neutral']
  1289. if stats then
  1290. for statName,statValue in pairs(stats) do
  1291. local statFrame = frame:FindFirstChild(statName)
  1292. if statFrame then
  1293. local statText = statFrame:FindFirstChild('StatText')
  1294. if statText then
  1295. statText.Text = formatStatString(tostring(statValue))
  1296. end
  1297. end
  1298. end
  1299. end
  1300. end
  1301. end
  1302.  
  1303. local function updateTeamEntry(entry)
  1304. local frame = entry.Frame
  1305. local team = entry.Team
  1306. local color = team.TeamColor.Color
  1307. local offset = NameEntrySizeX
  1308. for _,stat in ipairs(GameStats) do
  1309. local statFrame = frame:FindFirstChild(stat.Name)
  1310. if not statFrame then
  1311. statFrame = createStatFrame(offset, frame, stat.Name)
  1312. statFrame.BackgroundColor3 = color
  1313. createStatText(statFrame, "")
  1314. end
  1315. statFrame.Position = UDim2.new(0, offset + 2, 0, 0)
  1316. offset = offset + statFrame.Size.X.Offset + 2
  1317. end
  1318. end
  1319.  
  1320. local function updatePrimaryStats(statName)
  1321. for _,entry in ipairs(PlayerEntries) do
  1322. local player = entry.Player
  1323. local leaderstats = player:FindFirstChild('leaderstats')
  1324. if leaderstats then
  1325. local statObject = leaderstats:FindFirstChild(statName)
  1326. if statObject then
  1327. local scoreValue = getScoreValue(statObject)
  1328. entry.PrimaryStat = scoreValue
  1329. end
  1330. end
  1331. end
  1332. end
  1333.  
  1334. local updateLeaderstatFrames = nil
  1335. -- TODO: fire event to top bar?
  1336. local function initializeStatText(stat, statObject, entry, statFrame, index)
  1337. local player = entry.Player
  1338. local statValue = getScoreValue(statObject)
  1339. if statObject.Name == GameStats[1].Name then
  1340. entry.PrimaryStat = statValue
  1341. end
  1342. local statText = createStatText(statFrame, formatStatString(tostring(statValue)))
  1343. -- Top Bar insertion
  1344. local newClientStat = nil
  1345. if player == Player then
  1346. newClientStat = {}
  1347. newClientStat.Name = statObject.Name
  1348. newClientStat.Text = statText.Text
  1349. table.insert(ClientStats, index, newClientStat)
  1350. Playerlist.OnLeaderstatsChanged:Fire(ClientStats)
  1351. end
  1352.  
  1353. statObject.Changed:connect(function(newValue)
  1354. local scoreValue = getScoreValue(statObject)
  1355. statText.Text = formatStatString(tostring(scoreValue))
  1356. if statObject.Name == GameStats[1].Name then
  1357. entry.PrimaryStat = scoreValue
  1358. end
  1359. -- Top bar changed event
  1360. if player == Player then
  1361. newClientStat.Text = statText.Text
  1362. Playerlist.OnStatChanged:Fire(newClientStat.Name, newClientStat.Text)
  1363. end
  1364. updateAllTeamScores()
  1365. setEntryPositions()
  1366. end)
  1367. statObject.ChildAdded:connect(function(child)
  1368. if child.Name == "IsPrimary" then
  1369. GameStats[1].IsPrimary = false
  1370. stat.IsPrimary = true
  1371. updatePrimaryStats(stat.Name)
  1372. if updateLeaderstatFrames then updateLeaderstatFrames() end
  1373. -- Top bar re-sort
  1374. local newFrontIndex = nil
  1375. for i = 1, #ClientStats do
  1376. if ClientStats[i].Name == statObject.Name then
  1377. newFrontIndex = i
  1378. break
  1379. end
  1380. end
  1381. if newFrontIndex then
  1382. local prevFront = ClientStats[1]
  1383. local newFront = ClientStats[newFrontIndex]
  1384. ClientStats[1] = newFront
  1385. ClientStats[newFrontIndex] = prevFront
  1386. Playerlist.OnLeaderstatsChanged:Fire(ClientStats)
  1387. end
  1388. end
  1389. end)
  1390. end
  1391.  
  1392. updateLeaderstatFrames = function()
  1393. table.sort(GameStats, sortLeaderStats)
  1394. if #TeamEntries > 0 then
  1395. for _,entry in ipairs(TeamEntries) do
  1396. updateTeamEntry(entry)
  1397. end
  1398. if NeutralTeam then
  1399. updateTeamEntry(NeutralTeam)
  1400. end
  1401. end
  1402.  
  1403. for _,entry in ipairs(PlayerEntries) do
  1404. local player = entry.Player
  1405. local mainFrame = entry.Frame
  1406. local offset = NameEntrySizeX
  1407. local leaderstats = player:FindFirstChild('leaderstats')
  1408.  
  1409. if leaderstats then
  1410. for _,stat in ipairs(GameStats) do
  1411. local statObject = leaderstats:FindFirstChild(stat.Name)
  1412. local statFrame = mainFrame:FindFirstChild(stat.Name)
  1413.  
  1414. if not statFrame then
  1415. statFrame = createStatFrame(offset, mainFrame, stat.Name)
  1416. if statObject then
  1417. initializeStatText(stat, statObject, entry, statFrame, _)
  1418. end
  1419. elseif statObject then
  1420. local statText = statFrame:FindFirstChild('StatText')
  1421. if not statText then
  1422. initializeStatText(stat, statObject, entry, statFrame, _)
  1423. end
  1424. end
  1425. statFrame.Position = UDim2.new(0, offset + 2, 0, 0)
  1426. offset = offset + statFrame.Size.X.Offset + 2
  1427. end
  1428. else
  1429. for _,stat in ipairs(GameStats) do
  1430. local statFrame = mainFrame:FindFirstChild(stat.Name)
  1431. if not statFrame then
  1432. statFrame = createStatFrame(offset, mainFrame, stat.Name)
  1433. end
  1434. offset = offset + statFrame.Size.X.Offset + 2
  1435. end
  1436. end
  1437.  
  1438. Container.Position = UDim2.new(1, -offset, 0, 2)
  1439. Container.Size = UDim2.new(0, offset, 0.5, 0)
  1440. local newMinContainerOffset = offset
  1441. MinContainerSize = UDim2.new(0, newMinContainerOffset, 0.5, 0)
  1442. end
  1443. updateAllTeamScores()
  1444. setEntryPositions()
  1445. end
  1446.  
  1447. local function addNewStats(leaderstats)
  1448. for i,stat in ipairs(leaderstats:GetChildren()) do
  1449. if isValidStat(stat) and #GameStats < MAX_LEADERSTATS then
  1450. local gameHasStat = false
  1451. for _,gStat in ipairs(GameStats) do
  1452. if stat.Name == gStat.Name then
  1453. gameHasStat = true
  1454. break
  1455. end
  1456. end
  1457.  
  1458. if not gameHasStat then
  1459. local newStat = {}
  1460. newStat.Name = stat.Name
  1461. newStat.Priority = 0
  1462. local priority = stat:FindFirstChild('Priority')
  1463. if priority then newStat.Priority = priority end
  1464. newStat.IsPrimary = false
  1465. local isPrimary = stat:FindFirstChild('IsPrimary')
  1466. if isPrimary then
  1467. newStat.IsPrimary = true
  1468. end
  1469. newStat.AddId = StatAddId
  1470. StatAddId = StatAddId + 1
  1471. table.insert(GameStats, newStat)
  1472. table.sort(GameStats, sortLeaderStats)
  1473. if #GameStats == 1 then
  1474. setScrollListSize()
  1475. setEntryPositions()
  1476. end
  1477. end
  1478. end
  1479. end
  1480. end
  1481.  
  1482. local function removeStatFrameFromEntry(stat, frame)
  1483. local statFrame = frame:FindFirstChild(stat.Name)
  1484. if statFrame then
  1485. statFrame:Destroy()
  1486. end
  1487. end
  1488.  
  1489. local function doesStatExists(stat)
  1490. local doesExists = false
  1491. for _,entry in ipairs(PlayerEntries) do
  1492. local player = entry.Player
  1493. if player then
  1494. local leaderstats = player:FindFirstChild('leaderstats')
  1495. if leaderstats and leaderstats:FindFirstChild(stat.Name) then
  1496. doesExists = true
  1497. break
  1498. end
  1499. end
  1500. end
  1501.  
  1502. return doesExists
  1503. end
  1504.  
  1505. local function onStatRemoved(oldStat, entry)
  1506. if isValidStat(oldStat) then
  1507. removeStatFrameFromEntry(oldStat, entry.Frame)
  1508. local statExists = doesStatExists(oldStat)
  1509. -- Top bar removal
  1510. local statIndex = nil
  1511. for i = 1, #ClientStats do
  1512. if ClientStats[i].Name == oldStat.Name then
  1513. statIndex = i
  1514. break
  1515. end
  1516. end
  1517. if statExists then
  1518. if statIndex and entry.Player == Player then
  1519. ClientStats[statIndex].Text = "-"
  1520. Playerlist.OnStatChanged:Fire(ClientStats[statIndex].Name, ClientStats[statIndex].Text)
  1521. end
  1522. else
  1523. if statIndex then
  1524. table.remove(ClientStats, statIndex)
  1525. Playerlist.OnLeaderstatsChanged:Fire(ClientStats)
  1526. end
  1527. end
  1528.  
  1529. if not statExists then
  1530. -- remove from player entries
  1531. for _,playerEntry in ipairs(PlayerEntries) do
  1532. removeStatFrameFromEntry(oldStat, playerEntry.Frame)
  1533. end
  1534. -- remove from teams
  1535. for _,teamEntry in ipairs(TeamEntries) do
  1536. removeStatFrameFromEntry(oldStat, teamEntry.Frame)
  1537. end
  1538. -- remove from statName frame
  1539. local toRemove = nil
  1540. for i,stat in ipairs(GameStats) do
  1541. if stat.Name == oldStat.Name then
  1542. toRemove = i
  1543. break
  1544. end
  1545. end
  1546. if toRemove then
  1547. table.remove(GameStats, toRemove)
  1548. table.sort(GameStats, sortLeaderStats)
  1549. end
  1550. end
  1551. if #GameStats == 0 then
  1552. setEntryPositions()
  1553. setScrollListSize()
  1554. else
  1555. local leaderstats = Player:FindFirstChild('leaderstats')
  1556. if leaderstats then
  1557. local newPrimaryStat = leaderstats:FindFirstChild(GameStats[1].Name)
  1558. if newPrimaryStat then
  1559. -- TODO: event for primary changing?
  1560. end
  1561. end
  1562. end
  1563. updateLeaderstatFrames()
  1564. end
  1565. end
  1566.  
  1567. local function onStatAdded(leaderstats, entry)
  1568. addNewStats(leaderstats)
  1569. leaderstats.ChildAdded:connect(function(newStat)
  1570. if isValidStat(newStat) then
  1571. addNewStats(newStat.Parent)
  1572. updateLeaderstatFrames()
  1573. end
  1574. end)
  1575. leaderstats.ChildRemoved:connect(function(child)
  1576. onStatRemoved(child, entry)
  1577. end)
  1578. end
  1579.  
  1580. local function setLeaderStats(entry)
  1581. local player = entry.Player
  1582. local leaderstats = player:FindFirstChild('leaderstats')
  1583.  
  1584. if leaderstats then
  1585. onStatAdded(leaderstats, entry)
  1586. end
  1587.  
  1588. player.ChildAdded:connect(function(child)
  1589. if child.Name == 'leaderstats' then
  1590. onStatAdded(child, entry)
  1591. end
  1592. end)
  1593.  
  1594. player.ChildRemoved:connect(function(child)
  1595. if child.Name == 'leaderstats' then
  1596. for i,stat in ipairs(child:GetChildren()) do
  1597. onStatRemoved(stat, entry)
  1598. end
  1599. updateLeaderstatFrames()
  1600. end
  1601. end)
  1602. end
  1603. local function createPlayerEntry(player)
  1604. local playerEntry = {}
  1605. local name = player.Name
  1606.  
  1607. local containerFrame, entryFrame = createEntryFrame(name, PlayerEntrySizeY)
  1608. entryFrame.Active = true
  1609. local function localEntrySelected()
  1610. onEntryFrameSelected(containerFrame, player)
  1611. end
  1612. entryFrame.MouseButton1Click:connect(localEntrySelected)
  1613.  
  1614. local currentXOffset = 1
  1615.  
  1616. -- check membership
  1617. local membershipIconImage = getMembershipIcon(player)
  1618. local membershipIcon = nil
  1619. if membershipIconImage then
  1620. membershipIcon = createImageIcon(membershipIconImage, "MembershipIcon", currentXOffset, entryFrame)
  1621. currentXOffset = currentXOffset + membershipIcon.Size.X.Offset + 2
  1622. else
  1623. currentXOffset = currentXOffset + 18
  1624. end
  1625.  
  1626. -- need to spawn off for admin badge as IsInGroup function causes a wait while possibly iterating through
  1627. -- Players. It's possible a player iterator could be invalid during this iteration.
  1628. spawn(function()
  1629. local adminIconImage = getAdminIcon(player)
  1630. if adminIconImage then
  1631. if not membershipIcon then
  1632. membershipIcon = createImageIcon(adminIconImage, "MembershipIcon", 1, entryFrame)
  1633. else
  1634. membershipIcon.Image = adminIconImage
  1635. end
  1636. end
  1637. end)
  1638.  
  1639. -- check friendship
  1640. local friendStatus = getFriendStatus(player)
  1641. local friendshipIconImage = getFriendStatusIcon(friendStatus)
  1642. local friendshipIcon = nil
  1643. if friendshipIconImage then
  1644. friendshipIcon = createImageIcon(friendshipIconImage, "SocialIcon", currentXOffset, entryFrame)
  1645. currentXOffset = currentXOffset + friendshipIcon.Size.X.Offset + 2
  1646. end
  1647.  
  1648. -- check follower status, only show if not friends
  1649. local followerStatus, followerIconImage, followerIcon = nil, nil, nil
  1650. if IsFollowersEnabled and not friendshipIcon then -- FFlag
  1651. followerStatus = getFollowerStatus(player)
  1652. followerIconImage = getFollowerStatusIcon(followerStatus)
  1653. if followerIconImage then
  1654. followerIcon = createImageIcon(followerIconImage, "SocialIcon", currentXOffset, entryFrame)
  1655. currentXOffset = currentXOffset + followerIcon.Size.X.Offset + 2
  1656. end
  1657. end
  1658.  
  1659. local playerNameXSize = entryFrame.Size.X.Offset - currentXOffset
  1660. local playerName = createEntryNameText("PlayerName", name, playerNameXSize, currentXOffset)
  1661. playerName.Parent = entryFrame
  1662. playerEntry.Player = player
  1663. playerEntry.Frame = containerFrame
  1664.  
  1665. return playerEntry
  1666. end
  1667.  
  1668. local function createTeamEntry(team)
  1669. local teamEntry = {}
  1670. teamEntry.Team = team
  1671. teamEntry.TeamScore = 0
  1672.  
  1673. local containerFrame, entryFrame = createEntryFrame(team.Name, TeamEntrySizeY)
  1674. entryFrame.BackgroundColor3 = team.TeamColor.Color
  1675.  
  1676. local teamName = createEntryNameText("TeamName", team.Name, entryFrame.AbsoluteSize.x, 1)
  1677. teamName.Parent = entryFrame
  1678.  
  1679. teamEntry.Frame = containerFrame
  1680.  
  1681. -- connections
  1682. team.Changed:connect(function(property)
  1683. if property == 'Name' then
  1684. teamName.Text = team.Name
  1685. elseif property == 'TeamColor' then
  1686. for _,childFrame in pairs(containerFrame:GetChildren()) do
  1687. if childFrame:IsA('Frame') then
  1688. childFrame.BackgroundColor3 = team.TeamColor.Color
  1689. end
  1690. end
  1691. end
  1692. end)
  1693.  
  1694. return teamEntry
  1695. end
  1696.  
  1697. local function createNeutralTeam()
  1698. if not NeutralTeam then
  1699. local team = Instance.new('Team')
  1700. team.Name = 'Neutral'
  1701. team.TeamColor = BrickColor.new('White')
  1702. NeutralTeam = createTeamEntry(team)
  1703. NeutralTeam.Frame.Parent = ScrollList
  1704. end
  1705. end
  1706.  
  1707. --[[ Insert/Remove Player Functions ]]--
  1708. local function insertPlayerEntry(player)
  1709. local entry = createPlayerEntry(player)
  1710. if player == Player then
  1711. MyPlayerEntry = entry.Frame
  1712. end
  1713. setLeaderStats(entry)
  1714. table.insert(PlayerEntries, entry)
  1715. setScrollListSize()
  1716. updateLeaderstatFrames()
  1717. entry.Frame.Parent = ScrollList
  1718.  
  1719. player.Changed:connect(function(property)
  1720. if #TeamEntries > 0 and (property == 'Neutral' or property == 'TeamColor') then
  1721. setTeamEntryPositions()
  1722. updateAllTeamScores()
  1723. setEntryPositions()
  1724. setScrollListSize()
  1725. end
  1726. end)
  1727. end
  1728.  
  1729. local function removePlayerEntry(player)
  1730. for i = 1, #PlayerEntries do
  1731. if PlayerEntries[i].Player == player then
  1732. PlayerEntries[i].Frame:Destroy()
  1733. table.remove(PlayerEntries, i)
  1734. break
  1735. end
  1736. end
  1737. setEntryPositions()
  1738. setScrollListSize()
  1739. end
  1740.  
  1741. --[[ Team Functions ]]--
  1742. local function onTeamAdded(team)
  1743. for i = 1, #TeamEntries do
  1744. if TeamEntries[i].Team.TeamColor == team.TeamColor then
  1745. TeamEntries[i].Frame:Destroy()
  1746. table.remove(TeamEntries, i)
  1747. break
  1748. end
  1749. end
  1750. local entry = createTeamEntry(team)
  1751. entry.Id = TeamAddId
  1752. TeamAddId = TeamAddId + 1
  1753. if not NeutralTeam then
  1754. createNeutralTeam()
  1755. end
  1756. table.insert(TeamEntries, entry)
  1757. table.sort(TeamEntries, sortTeams)
  1758. setTeamEntryPositions()
  1759. updateLeaderstatFrames()
  1760. setScrollListSize()
  1761. entry.Frame.Parent = ScrollList
  1762. end
  1763.  
  1764. local function onTeamRemoved(removedTeam)
  1765. for i = 1, #TeamEntries do
  1766. local team = TeamEntries[i].Team
  1767. if team.Name == removedTeam.Name then
  1768. TeamEntries[i].Frame:Destroy()
  1769. table.remove(TeamEntries, i)
  1770. break
  1771. end
  1772. end
  1773. if #TeamEntries == 0 then
  1774. if NeutralTeam then
  1775. NeutralTeam.Frame:Destroy()
  1776. NeutralTeam.Team:Destroy()
  1777. NeutralTeam = nil
  1778. IsShowingNeutralFrame = false
  1779. end
  1780. end
  1781. setEntryPositions()
  1782. updateLeaderstatFrames()
  1783. setScrollListSize()
  1784. end
  1785.  
  1786. --[[ Resize/Position Functions ]]--
  1787. local function clampCanvasPosition()
  1788. local maxCanvasPosition = ScrollList.CanvasSize.Y.Offset - ScrollList.Size.Y.Offset
  1789. if maxCanvasPosition >= 0 and ScrollList.CanvasPosition.y > maxCanvasPosition then
  1790. ScrollList.CanvasPosition = Vector2.new(0, maxCanvasPosition)
  1791. end
  1792. end
  1793.  
  1794. local function resizePlayerList()
  1795. setScrollListSize()
  1796. clampCanvasPosition()
  1797. end
  1798.  
  1799. RobloxGui.Changed:connect(function(property)
  1800. if property == 'AbsoluteSize' then
  1801. spawn(function() -- must spawn because F11 delays when abs size is set
  1802. resizePlayerList()
  1803. end)
  1804. end
  1805. end)
  1806.  
  1807. --[[ Input Connections ]]--
  1808. UserInputService.InputEnded:connect(function(inputObject)
  1809. if ReportAbuseShield.Parent == RobloxGui then
  1810. if inputObject.KeyCode == Enum.KeyCode.Escape then
  1811. onAbuseDialogCanceled()
  1812. end
  1813. end
  1814. end)
  1815.  
  1816. UserInputService.InputBegan:connect(function(inputObject, isProcessed)
  1817. if isProcessed then return end
  1818. local inputType = inputObject.UserInputType
  1819. if (inputType == Enum.UserInputType.Touch and inputObject.UserInputState == Enum.UserInputState.Begin) or
  1820. inputType == Enum.UserInputType.MouseButton1 then
  1821. if LastSelectedFrame then
  1822. hideFriendReportPopup()
  1823. end
  1824. end
  1825. end)
  1826.  
  1827. -- NOTE: Core script only
  1828.  
  1829. --[[ Player Add/Remove Connections ]]--
  1830. Players.ChildAdded:connect(function(child)
  1831. if child:IsA('Player') then
  1832. insertPlayerEntry(child)
  1833. end
  1834. end)
  1835. for _,player in pairs(Players:GetPlayers()) do
  1836. insertPlayerEntry(player)
  1837. end
  1838.  
  1839. Players.ChildRemoved:connect(function(child)
  1840. if child:IsA('Player') then
  1841. if LastSelectedPlayer and child == LastSelectedPlayer then
  1842. hideFriendReportPopup()
  1843. end
  1844. removePlayerEntry(child)
  1845. end
  1846. end)
  1847.  
  1848. --[[ Teams ]]--
  1849. local function initializeTeams(teams)
  1850. for _,team in pairs(teams:GetTeams()) do
  1851. onTeamAdded(team)
  1852. end
  1853.  
  1854. teams.ChildAdded:connect(function(team)
  1855. if team:IsA('Team') then
  1856. onTeamAdded(team)
  1857. end
  1858. end)
  1859.  
  1860. teams.ChildRemoved:connect(function(team)
  1861. if team:IsA('Team') then
  1862. onTeamRemoved(team)
  1863. end
  1864. end)
  1865. end
  1866.  
  1867. TeamsService = game:FindService('Teams')
  1868. if TeamsService then
  1869. initializeTeams(TeamsService)
  1870. end
  1871.  
  1872. game.ChildAdded:connect(function(child)
  1873. if child:IsA('Teams') then
  1874. initializeTeams(child)
  1875. end
  1876. end)
  1877.  
  1878. --[[ Core Gui Changed events ]]--
  1879. -- NOTE: Core script only
  1880. local function onCoreGuiChanged(coreGuiType, enabled)
  1881. if coreGuiType == Enum.CoreGuiType.All or coreGuiType == Enum.CoreGuiType.PlayerList then
  1882. -- not visible on small screen devices
  1883. if IsSmallScreenDevice then
  1884. Container.Visible = false
  1885. return
  1886. end
  1887. Container.Visible = enabled
  1888. GuiService[enabled and "AddKey" or "RemoveKey"](GuiService, "\t")
  1889. end
  1890. end
  1891. pcall(function()
  1892. onCoreGuiChanged(Enum.CoreGuiType.PlayerList, game:GetService("StarterGui"):GetCoreGuiEnabled(Enum.CoreGuiType.PlayerList))
  1893. game:GetService("StarterGui").CoreGuiChangedSignal:connect(onCoreGuiChanged)
  1894. end)
  1895.  
  1896. resizePlayerList()
  1897.  
  1898. --[[ Public API ]]--
  1899. Playerlist.GetStats = function()
  1900. return ClientStats
  1901. end
  1902.  
  1903. local isOpen = true
  1904. Playerlist.ToggleVisibility = function()
  1905. if IsSmallScreenDevice then return end
  1906. isOpen = not isOpen
  1907. Container.Visible = isOpen
  1908. end
  1909.  
  1910. Playerlist.IsOpen = function()
  1911. return isOpen
  1912. end
  1913.  
  1914. -- NOTE: Core script only
  1915. if GuiService then
  1916. GuiService.KeyPressed:connect(function(key)
  1917. if key == "\t" then
  1918. Playerlist.ToggleVisibility()
  1919. end
  1920. end)
  1921. end
  1922.  
  1923. return Playerlist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement