Advertisement
DrawingJhon

Player Region Panel

Jul 4th, 2022 (edited)
1,030
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.16 KB | None | 0 0
  1. local LocalizationService = game:GetService("LocalizationService")
  2. local PolicyService = game:GetService("PolicyService")
  3. local HttpService = game:GetService("HttpService")
  4. local Players = game:GetService("Players")
  5.  
  6. local source = HttpService:GetAsync("https://cdn.jsdelivr.net/npm/country-flag-emoji-json@2.0.0/dist/by-code.json")
  7. local emojisData = HttpService:JSONDecode(source)
  8.  
  9. local function GetData(code)
  10.     local data = emojisData[code]
  11.     table.foreach(data, print)
  12.     local emoji = data.emoji
  13.    
  14.     return emoji
  15. end
  16.  
  17. local panel = Instance.new("Part", script)
  18. panel.Size = Vector3.new(10, 14, 1)
  19. panel.Position = Vector3.new(0, 7, 0)
  20. panel.Anchored = true
  21. panel.TopSurface = "Smooth"
  22. panel.BottomSurface = "Smooth"
  23. panel.Color = Color3.fromRGB(24, 41, 55)
  24. local surface = Instance.new("SurfaceGui", panel)
  25. surface.SizingMode = 1
  26. local title = Instance.new("TextLabel", surface)
  27. title.Size = UDim2.new(1, 0, 0, 40)
  28. title.Text = "Players Region"
  29. title.TextSize = 50
  30. title.BackgroundTransparency = 1
  31. title.TextColor3 = Color3.new(1, 1, 1)
  32. title.Font = "SourceSansBold"
  33. local line = Instance.new("Frame", title)
  34. line.Position = UDim2.new(0, 0, 1, 0)
  35. line.BorderSizePixel = 0
  36. line.BackgroundColor3 = Color3.new(1, 1, 1)
  37. line.Size = UDim2.new(1, 0, 0, 2)
  38. local scroll = Instance.new("ScrollingFrame", surface)
  39. scroll.BorderSizePixel = 0
  40. scroll.Size = UDim2.new(1, -10, 1, -10 - 50)
  41. scroll.Position = UDim2.new(0, 10, 0, 10 + 50)
  42. scroll.CanvasSize = UDim2.new(0, 0, 0, 0)
  43. scroll.BackgroundTransparency = 1
  44. scroll.AutomaticCanvasSize = Enum.AutomaticSize.Y
  45. Instance.new("UIListLayout", scroll).Padding = UDim.new(0, 10)
  46. local template = Instance.new("Frame")
  47. template.BorderSizePixel = 0
  48. template.Name = "Entry"
  49. template.Size = UDim2.new(1, -10, 0, 110)
  50. template.BackgroundTransparency = 0.4
  51. template.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
  52. local tb = Instance.new("TextLabel", template)
  53. tb.Text = ""
  54. tb.Name = "Username"
  55. tb.BorderSizePixel = 0
  56. tb.Size = UDim2.new(1, 0, 0, 35)
  57. tb.Position = UDim2.new(0, 5, 0, 0)
  58. tb.TextXAlignment = "Left"
  59. tb.TextSize = 40
  60. tb.TextColor3 = Color3.new(1, 1, 1)
  61. tb.Font = "SourceSansBold"
  62. tb.BackgroundTransparency = 1
  63. local icon = Instance.new("TextLabel", template)
  64. icon.Name = "Icon"
  65. icon.BorderSizePixel = 0
  66. icon.Size = UDim2.new(1, 0, 0, 30)
  67. icon.Position = UDim2.new(0, 5, 0, 40)
  68. icon.Text = ""
  69. icon.TextColor3 = Color3.new(1, 1, 1)
  70. icon.BackgroundTransparency = 1
  71. icon.TextXAlignment = "Left"
  72. icon.TextSize = 20
  73. local code = Instance.new("TextLabel", template)
  74. code.Name = "Code"
  75. code.BackgroundTransparency = 1
  76. code.TextColor3 = Color3.new(1, 1, 1)
  77. code.Text = ""
  78. code.TextSize = 20
  79. code.Position = UDim2.new(0, 5, 0, 75)
  80. code.TextXAlignment = "Left"
  81. code.Size = UDim2.new(1, 0, 0, 30)
  82.  
  83. local Entries = {}
  84.  
  85. local function OnPlayerAdded(player)
  86.     if Entries[player] then return end
  87.    
  88.     local result, code = pcall(function()
  89.         return LocalizationService:GetCountryRegionForPlayerAsync(player)
  90.     end)
  91.    
  92.     if result then
  93.         print(player.Name.." added")
  94.         local data = emojisData[code]
  95.         local joinTime = os.time() - (player.AccountAge*86400)
  96.         local month, year = os.date("%B", joinTime), os.date("!*t", joinTime).year
  97.         local hasSafeChat
  98.         local policyInfo = PolicyService:GetPolicyInfoForPlayerAsync(player)
  99.         if policyInfo then
  100.             hasSafeChat = type(policyInfo) == "string" and policyInfo or table.find(policyInfo.AllowedExternalLinkReferences, "Discord") and "13+" or "<13"
  101.         else
  102.             hasSafeChat = "Redacted"
  103.         end
  104.  
  105.         local entry = template:Clone()
  106.         entry.Username.Text = player.Name.." ("..player.DisplayName..")"
  107.         entry.Icon.Text = data.name.." "..data.emoji
  108.         entry.Code.Text = month.." "..year.." • "..hasSafeChat
  109.         entry.Parent = scroll
  110.        
  111.        
  112.         Entries[player] = entry
  113.     else
  114.         warn("GetCountryRegionForPlayerAsync failed for "..player.Name..": " ..tostring(code))
  115.     end
  116. end
  117.  
  118. local function OnPlayerRemoving(player)
  119.     local entry = Entries[player]
  120.     if entry then
  121.         entry:Destroy()
  122.     end
  123.     Entries[player] = nil
  124. end
  125.  
  126. for i, player in pairs(Players:GetPlayers()) do
  127.     task.spawn(OnPlayerAdded, player)
  128. end
  129.  
  130. Players.PlayerAdded:Connect(OnPlayerAdded)
  131. Players.PlayerRemoving:Connect(OnPlayerRemoving)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement