Advertisement
Sungmingamerpro13

Titles System In ServerScriptService (STORY GAME)

Nov 21st, 2024 (edited)
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 4.67 KB | None | 0 0
  1. local TitlesEvent = game.ReplicatedStorage.TitlesEvent
  2. local DataStore = game:GetService("DataStoreService"):GetDataStore("Rank")
  3. local Players = game:GetService("Players")
  4.  
  5. local ClonedGui = script:WaitForChild("OverHead"):Clone()
  6.  
  7. Players.PlayerAdded:Connect(function(player)
  8.     player.CharacterAdded:Connect(function(char)
  9.        
  10.         local Rank = Instance.new("StringValue", player)
  11.         Rank.Name = "Rank"
  12.         Rank.Value = player.Rank.Value
  13.        
  14.         ClonedGui.Parent = char.Head
  15.        
  16.         local PlayerName = player.Name
  17.        
  18.         ClonedGui.nameLabel.Text = PlayerName
  19.         ClonedGui.titleLabel.Text = Rank.Value
  20.        
  21.         TitlesEvent.PremiumEvent.OnServerEvent:Connect(function(player)
  22.             player.Rank.Value = "Premium"
  23.             ClonedGui.titleLabel.Text = player.Rank.Value
  24.             ClonedGui.titleLabel.UIGradient.Enabled = true
  25.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  26.         end)
  27.        
  28.         TitlesEvent.NoneEvent.OnServerEvent:Connect(function(player)
  29.             player.Rank.Value = ""
  30.             ClonedGui.titleLabel.Text = player.Rank.Value
  31.             ClonedGui.titleLabel.UIGradient.Enabled = false
  32.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  33.         end)
  34.  
  35.         TitlesEvent.NoviceEvent.OnServerEvent:Connect(function(player)
  36.             player.Rank.Value = "NOVICE"
  37.             ClonedGui.titleLabel.Text = player.Rank.Value
  38.             ClonedGui.titleLabel.UIGradient.Enabled = false
  39.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  40.         end)
  41.        
  42.         TitlesEvent.NoviceEvent.OnServerEvent:Connect(function(player)
  43.             player.Rank.Value = "ROOKIE"
  44.             ClonedGui.titleLabel.Text = player.Rank.Value
  45.             ClonedGui.titleLabel.UIGradient.Enabled = false
  46.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  47.         end)
  48.        
  49.         TitlesEvent.VisitorEvent.OnServerEvent:Connect(function(player)
  50.             player.Rank.Value = "VISITOR"
  51.             ClonedGui.titleLabel.Text = player.Rank.Value
  52.             ClonedGui.titleLabel.UIGradient.Enabled = false
  53.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  54.         end)
  55.        
  56.         TitlesEvent.CitizenEvent.OnServerEvent:Connect(function(player)
  57.             player.Rank.Value = "CITIZEN"
  58.             ClonedGui.titleLabel.Text = player.Rank.Value
  59.             ClonedGui.titleLabel.UIGradient.Enabled = false
  60.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  61.         end)
  62.        
  63.         TitlesEvent.PackagerEvent.OnServerEvent:Connect(function(player)
  64.             player.Rank.Value = "PACKAGER"
  65.             ClonedGui.titleLabel.Text = player.Rank.Value
  66.             ClonedGui.titleLabel.UIGradient.Enabled = false
  67.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  68.         end)
  69.        
  70.         TitlesEvent.NeighborEvent.OnServerEvent:Connect(function(player)
  71.             player.Rank.Value = "NEIGHBOR"
  72.             ClonedGui.titleLabel.Text = player.Rank.Value
  73.             ClonedGui.titleLabel.UIGradient.Enabled = false
  74.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  75.         end)
  76.  
  77.         TitlesEvent.ChampionEvent.OnServerEvent:Connect(function(player)
  78.             player.Rank.Value = "CHAMPION"
  79.             ClonedGui.titleLabel.Text = player.Rank.Value
  80.             ClonedGui.titleLabel.UIGradient.Enabled = false
  81.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  82.         end)
  83.        
  84.         TitlesEvent.LandLordEvent.OnServerEvent:Connect(function(player)
  85.             player.Rank.Value = "LANDLORD"
  86.             ClonedGui.titleLabel.Text = player.Rank.Value
  87.             ClonedGui.titleLabel.UIGradient.Enabled = false
  88.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  89.         end)
  90.        
  91.         TitlesEvent.BeastEvent.OnServerEvent:Connect(function(player)
  92.             player.Rank.Value = "BEAST"
  93.             ClonedGui.titleLabel.Text = player.Rank.Value
  94.             ClonedGui.titleLabel.UIGradient.Enabled = false
  95.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  96.         end)
  97.        
  98.         TitlesEvent.WinnerEvent.OnServerEvent:Connect(function(player)
  99.             player.Rank.Value = "WINNER"
  100.             ClonedGui.titleLabel.Text = player.Rank.Value
  101.             ClonedGui.titleLabel.UIGradient.Enabled = false
  102.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 1)
  103.         end)
  104.        
  105.         TitlesEvent.VIPEvent.OnServerEvent:Connect(function(player)
  106.             player.Rank.Value = "VIP"
  107.             ClonedGui.titleLabel.Text = player.Rank.Value
  108.             ClonedGui.titleLabel.UIGradient.Enabled = false
  109.             ClonedGui.titleLabel.TextColor3 = Color3.new(1, 1, 0)
  110.         end)
  111.  
  112.     end)
  113. end)
  114.  
  115. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  116.     print("STOPPED!")
  117.  
  118.     for i,player in pairs(game.Players:GetPlayers()) do
  119.         local value = player.Rank.Value
  120.         DataStore:SetAsync(player.UserId, value)
  121.         print("Saved data for "..player.Name)
  122.     end
  123. end)
  124.  
  125. Players.PlayerRemoving:Connect(function(player)
  126.     local value = player.Rank.Value
  127.  
  128.     if value ~= nil then
  129.         print("Found data to save for "..player.Name.."!")
  130.         DataStore:SetAsync(player.UserId, value)
  131.         print("Saved data for "..player.Name)
  132.     else
  133.         print("Did not manage to find data to save for "..player.Name.."!")
  134.     end
  135. end)
  136.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement