Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.65 KB | None | 0 0
  1. PointsStore = game:GetService("DataStoreService"):GetDataStore("Points")
  2. LevelStore = game:GetService("DataStoreService"):GetDataStore("Level")
  3. XpStore = game:GetService("DataStoreService"):GetDataStore("Xp")
  4. PlayedStore = game:GetService("DataStoreService"):GetDataStore("Games played")
  5. WonStore = game:GetService("DataStoreService"):GetDataStore("Games won")
  6. LostStore = game:GetService("DataStoreService"):GetDataStore("Games lost")
  7.  
  8. function onxpchanged(player, level, xp)
  9.     if xp.Value >= level.Value * 125 then
  10.         xp.Value = xp.Value - level.Value * 125
  11.         level.Value = level.Value + 1
  12.     end
  13. end
  14.  
  15. function onlevelchanged(player, level)
  16.     for i, v in pairs(player.PlayerGui.ScreenGui.UpdFrame:GetChildren()) do
  17.         v:Destroy()
  18.     end
  19.    
  20.     local note = script.TextLabel
  21.     local noteclone = note:Clone()
  22.    
  23.     noteclone.Text = "Level " .. level.Value .. " achieved!"
  24.     noteclone.Parent = player.PlayerGui.ScreenGui.UpdFrame
  25.     for i = 1, 0, -0.05 do
  26.         noteclone.TextStrokeTransparency = i
  27.         noteclone.TextTransparency = i
  28.         wait()
  29.     end
  30.     wait(1.5)
  31.     for i = 0, 1, 0.05 do
  32.         noteclone.TextStrokeTransparency = i
  33.         noteclone.TextTransparency = i
  34.         wait()
  35.     end
  36.     noteclone:Destroy()
  37. end
  38.  
  39. game.Players.PlayerAdded:connect(function(player)
  40.     player:WaitForDataReady()
  41.    
  42.     local stats = Instance.new("IntValue", player)
  43.     stats.Name = "leaderstats"
  44.    
  45.     local points = Instance.new("IntValue", stats)
  46.     points.Name = "Points"
  47.    
  48.     local otherstats = Instance.new("IntValue", player)
  49.     otherstats.Name = "localstats"
  50.    
  51.     local level = Instance.new("IntValue", otherstats)
  52.     level.Name = "Level"
  53.    
  54.     local xp = Instance.new("IntValue", otherstats)
  55.     xp.Name = "Xp"
  56.    
  57.     local ingame = Instance.new("BoolValue", player)
  58.     ingame.Name = "Ingame"
  59.     ingame.Value = false
  60.    
  61.     local isplaying = Instance.new("BoolValue", player)
  62.     isplaying.Name = "Isplaying"
  63.     isplaying.Value = true
  64.    
  65.         local personalstats = Instance.new("IntValue", player)
  66.         personalstats.Name = "personalstats"
  67.        
  68.         local gplayed = Instance.new("IntValue", personalstats)
  69.         gplayed.Name = "Games played"
  70.        
  71.         local gwon = Instance.new("IntValue", personalstats)
  72.         gwon.Name = "Games won"
  73.        
  74.         local glost = Instance.new("IntValue", personalstats)
  75.         glost.Name = "Games lost"
  76.    
  77.     if PointsStore:GetAsync(player.Name) ~= nil then
  78.         points.Value = PointsStore:GetAsync(player.Name)
  79.     else
  80.         points.Value = 0
  81.     end
  82.    
  83.     if LevelStore:GetAsync(player.Name) ~= nil then
  84.         level.Value = LevelStore:GetAsync(player.Name)
  85.     else
  86.         level.Value = 1
  87.     end
  88.  
  89.     if XpStore:GetAsync(player.Name) ~= nil then
  90.         xp.Value = XpStore:GetAsync(player.Name)
  91.     else
  92.         xp.Value = 0
  93.     end
  94.    
  95.         if PlayedStore:GetAsync(player.Name) ~= nil then
  96.             gplayed.Value = PlayedStore:GetAsync(player.Name)
  97.         else
  98.             gplayed.Value = 0
  99.         end
  100.        
  101.         if WonStore:GetAsync(player.Name) ~= nil then
  102.             gwon.Value = WonStore:GetAsync(player.Name)
  103.         else
  104.             gwon.Value = 0
  105.         end
  106.    
  107.         if LostStore:GetAsync(player.Name) ~= nil then
  108.             glost.Value = LostStore:GetAsync(player.Name)
  109.         else
  110.             glost.Value = 0
  111.         end
  112.        
  113.     points.Changed:connect(function(update)
  114.         PointsStore:SetAsync(player.Name, update)
  115.     end)
  116.    
  117.     level.Changed:connect(function(update)
  118.         LevelStore:SetAsync(player.Name, update)
  119.         onlevelchanged(player, level)
  120.     end)
  121.  
  122.     xp.Changed:connect(function(update)
  123.         XpStore:SetAsync(player.Name, update)
  124.         onxpchanged(player, level, xp)
  125.     end)
  126.    
  127.         gplayed.Changed:connect(function(update)
  128.             PlayedStore:SetAsync(player.Name, update)
  129.         end)
  130.        
  131.         gwon.Changed:connect(function(update)
  132.             WonStore:SetAsync(player.Name, update)
  133.         end)
  134.        
  135.         glost.Changed:connect(function(update)
  136.             LostStore:SetAsync(player.Name, update)
  137.         end)
  138. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement