Sir_Spaceboi

code

Oct 10th, 2021
915
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.22 KB | None | 0 0
  1. local configurationModule = require(game.ReplicatedStorage:WaitForChild("Configuration"))
  2. local group = {configurationModule.GroupId, configurationModule.MiddleRank, configurationModule.HighRank}
  3. local tweenService = game:GetService("TweenService")
  4. local Players = game:GetService("Players")
  5. local datastoreService = game:GetService("DataStoreService")
  6. local OrdersBase = datastoreService:GetOrderedDataStore("Orders")
  7.  
  8. -- SetUp Nametag Function
  9. function setupNametag(Player, Character)
  10.     local NametagObject = game.ServerStorage:WaitForChild("NameTag")
  11.  
  12.     local info = TweenInfo.new(1.5, Enum.EasingStyle.Back, Enum.EasingDirection.InOut)
  13.     local info2 = TweenInfo.new(.8, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
  14.     local PlayerName = Player.Name
  15.     local PlayerDisplayName = Player.DisplayName
  16.     local PlayerRole
  17.     local PlayerRank = Player:GetRankInGroup(group[1])
  18.  
  19.     local ForceField = Character:FindFirstChildWhichIsA("ForceField")
  20.  
  21.     pcall(function()
  22.         PlayerRole = Player:GetRoleInGroup(group[1])
  23.     end)
  24.  
  25.     local Head = Character:FindFirstChild("Head")
  26.     local Humanoid = Character:WaitForChild("Humanoid")
  27.     if Head then
  28.         local NametagClone = NametagObject:Clone()
  29.  
  30.         NametagClone.Parent = Player.Character.HumanoidRootPart
  31.         NametagClone.StudsOffset = Vector3.new(0, Character.Head.Size.Y, 0) + Vector3.new(0, 2.5, 0)
  32.         NametagClone.Name = PlayerName
  33.  
  34.         NametagClone.Frame.Username.Text = PlayerName
  35.         NametagClone.Frame.Rank.Text = PlayerRole
  36.  
  37.         local RankTag = NametagClone.Frame.Rank
  38.         local NameTag = NametagClone.Frame.Username
  39.         local IconsFrame = NametagClone.Frame.Icons
  40.  
  41.         local tween1 = tweenService:Create(NameTag, info, {Position = UDim2.new(0, 0, 0.25, 0)})
  42.         local tween2 = tweenService:Create(RankTag, info, {Position = UDim2.new(0, 0, 0.5, 0)})
  43.         local tween3 = tweenService:Create(IconsFrame, info, {Position = UDim2.new(0.054, 0, 0, 0)})
  44.  
  45.         tween1:Play()
  46.         tween2:Play()
  47.         tween3:Play()
  48.  
  49.         tween3.Completed:Wait()
  50.  
  51.         Humanoid.DisplayDistanceType = "None"
  52.  
  53.         local Images = NametagClone.Frame.Icons
  54.  
  55.         if Player:GetRankInGroup(group[1]) == configurationModule.Owner then
  56.             local colorTween = tweenService:Create(NameTag, info2, {TextColor3 = Color3.fromRGB(76, 118, 255)})
  57.             colorTween:Play()
  58.         end
  59.  
  60.         if Player.UserId == 1788016643 then
  61.             local colorTween = tweenService:Create(NameTag, info2, {TextColor3 = Color3.fromRGB(188, 170, 241)})
  62.             colorTween:Play()
  63.         end
  64.         if Player.UserId == 1782889630 then
  65.             local colorTween = tweenService:Create(NameTag, info2, {TextColor3 = Color3.fromRGB(52, 59, 91)})
  66.             colorTween:Play()
  67.         end
  68.  
  69.         if Player:GetRankInGroup(group[1]) == configurationModule.Contributor then
  70.             local colorTween = tweenService:Create(NameTag, info2, {TextColor3 = Color3.fromRGB(209, 177, 13)})
  71.             colorTween:Play()
  72.         end
  73.  
  74.         if Player.UserId == 1788016643 or Player:GetRankInGroup(configurationModule.GroupId) == configurationModule.Owner then
  75.             Images.Pirate.Visible = true
  76.         end
  77.  
  78.         if Player:GetRankInGroup(configurationModule.GroupId) >= configurationModule.HighRank then
  79.             Images.Executive.Visible = true
  80.         end
  81.  
  82.         if Player:GetRankInGroup(configurationModule.GroupId) >= configurationModule.MiddleRank then
  83.             Images.Staff.Visible = true
  84.         end
  85.  
  86.         if Player:GetRankInGroup(configurationModule.GroupId) == configurationModule.Represenative then
  87.             Images.Represenative.Visible = true
  88.         end
  89.  
  90.         if Player:GetRankInGroup(configurationModule.GroupId) == configurationModule.DeveloperRank or Player:GetRankInGroup(configurationModule.GroupId) == configurationModule.Owner then
  91.             Images.Developer.Visible = true
  92.         end
  93.  
  94.         wait(.5)
  95.  
  96.         for Index, Image in pairs(IconsFrame:GetChildren()) do -- Must always be at the end of the script
  97.             if Image:IsA("ImageLabel") then
  98.                 local imageTransparencyTween = tweenService:Create(Image, info, {ImageTransparency = 0})
  99.                 imageTransparencyTween:Play()
  100.             end
  101.         end
  102.     end
  103. end
  104.  
  105. function setupStaff(Player)
  106.     if Player:GetRankInGroup(group[1]) >= group[2] and Player:GetRankInGroup(group[1]) < group[3] then
  107.         local staffFolder = script.Staff:Clone()
  108.         staffFolder.Orders.Value = OrdersBase:GetAsync(Player.UserId)
  109.         staffFolder.Parent = Player
  110.     elseif Player:GetRankInGroup(group[1]) >= group[3] then
  111.         local hour = DateTime.now():FormatUniversalTime("HH", "en-us")
  112.         local minute = DateTime.now():FormatUniversalTime("mm", "en-us")
  113.         local second = DateTime.now():FormatUniversalTime("ss", "en-us")
  114.         local staffFolder = script.Staff:Clone()
  115.  
  116.         staffFolder.Parent = Player
  117.         staffFolder.OrdersCreated.Value = OrdersBase:GetAsync(Player.UserId)
  118.         staffFolder.JoinTime.Value = hour .. ":" .. minute .. ":" .. second
  119.        
  120.         print(Player.Staff.OrdersCreated.Value)
  121.         print(Player.Staff.JoinTime.Value)
  122.     end
  123. end
  124.  
  125. -- Player Added Function
  126. Players.PlayerAdded:Connect(function(Player)   
  127.     print(configurationModule.GroupId)
  128.     print(configurationModule.Owner)
  129.     setupNametag(Player, Player.Character);
  130.     if Player:GetRankInGroup(configurationModule.GroupId) == configurationModule.Owner then
  131.         print("Staff Joined")
  132.         setupStaff(Player)
  133.     end
  134.    
  135.     Player.CharacterAdded:Connect(function(char)
  136.         if not char.HumanoidRootPart:FindFirstChild('NameTag') then
  137.             setupNametag(Player, Player.Character or Player.CharacterAdded:Wait())
  138.         end
  139.     end)
  140. end)
Advertisement
Add Comment
Please, Sign In to add comment