Nightmaare420

Freddie Mercury was gay but he was a good man

Nov 13th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.00 KB | None | 0 0
  1. local DS = game:GetService('DataStoreService')
  2. local SS = game:GetService('ServerStorage')
  3. local tableData = DS:GetDataStore('Stats')
  4. local LS = SS:WaitForChild('LvlStats')
  5.  
  6. local startData = {
  7.     Lvl = 1, XP = 0, MXP = 500
  8. } --Table for Data
  9.  
  10. game.Players.PlayerAdded:Connect(function(plr) --Function will run when a player joins
  11.     local stFolder = Instance.new('Folder') --Creating a new folder and setting the player that joins as its parent
  12.     stFolder.Name = "Stats"
  13.     stFolder.Parent = plr
  14.     local Data
  15.     Data = tableData:GetAsync(plr.userId) --Acquiring Data
  16.     for i,v in pairs(startData) do --Indexing startData table
  17.     if type(v) == 'number' then -- If the table cotains a value that is a number it will create an interger
  18.     local Num = Instance.new('IntValue')
  19.         Num.Name = i
  20.         Num.Value = v
  21.         Num.Parent = stFolder
  22.     elseif type(v) == 'boolean' then -- If its a true or false value it will create a boolvalue
  23.         local Bool = Instance.new('BoolValue')
  24.         Bool.Name = i
  25.         Bool.Value = v
  26.         Bool.Parent = stFolder
  27.     elseif type(v) == 'string' then -- If its letters or anything in quotation marks it will create a string value
  28.         local Ito = Instance.new('StringValue')
  29.         Ito.Name = i
  30.         Ito.Value = v
  31.         Ito.Parent = stFolder
  32. end
  33.     end
  34.    
  35.     if Data then --Checking if getting data with GetAsync() did not return a nil value
  36.         for i,v in pairs(Data) do --If it does then the values that was created before will be set to the data got from datastoreserver
  37.             plr.Stats[i].Value = v
  38.         end
  39.     end
  40.     plr.Stats.XP.Changed:Connect(function(plr) --Simple level up system, this function will activate whenever the xp value is changed
  41.         if plr.Stats.XP.Value >= plr.Stats.MXP.Value then --Checking if the xp value is higher than max xp value
  42.             plr.Stats.XP.Value = plr.Stats.XP.Value - plr.Stats.MXP.Value
  43.             plr.Stats.MXP.Value = plr.Stats.MXP.Value * 1.25 --Adding 1 lvl and multiplying the max xp value by 1.25
  44.             plr.Stats.Lvl.Value = plr.Stats.Lvl.Value + 1
  45.         end
  46.     end)
  47. end)
  48.  
  49. game.Players.PlayerRemoving:Connect(function(plr) --function will run upon a player leaves the game
  50.     local Data = {} --creating a table without any values atm
  51.     for i,v in pairs(plr.Stats:GetChildren()) do --indexing the stats folder on the player that left
  52.     Data[v.Name] = v.Value --creating the values that was in the stats folder into the table
  53.     end
  54.     tableData:SetAsync(plr.userId, Data) --saving the table in datastore
  55. end)
  56.  
  57. ----------------------------
  58.  
  59. game.Players.PlayerAdded:Connect(function(plr) --Waiting for a player to join event
  60.     local char = plr.Character or plr.CharacterAdded:Wait() -- Getting the player's character
  61.     for i,v in pairs(char:GetChildren()) do --looping through the character only finding all r15 parts except for the head
  62.         if v:IsA('MeshPart') then
  63.             v.Transparency = 1
  64.             local BV = Instance.new('BodyVelocity') --Setting transparency to 1 making floating head
  65.             BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  66.             BV.Velocity = Vector3.new(0,100,0) --[[becoming a shooting star leaping through the sky, like a tiger, defying the laws of gravity, I'm a racing car, passing by, like lady godiva, im gonna go go go, theres no stopping mee, im burning through the sky yea, 200 degrees thats why they call me mr fahrenheit, traveling at the speed of light, i wanna make a supersonic man out of you.]]
  67. --[[Im a rocket ship on my way to mars, on a collision course, i am a satellite, im out of control, im a sex machin ready to explode, like an atom bomb, im gonna oh oh oh oh explode]]
  68.             BV.Parent = plr.Character.HumanoidRootPart
  69.         end
  70.     end
  71.    
  72.             local Sound = Instance.new('Sound') --creating a sound and setting it to where the player can hear
  73.             Sound.SoundId = 'rbxassetid://3455283612' --Don't Stop Me Now by Queen
  74.             Sound.Parent = plr.Character.Head
  75.             if not Sound.IsLoaded then --waiting for the song to fully load
  76.                 Sound.Loaded:Wait()
  77.             end
  78.             Sound.TimePosition = 28.5
  79.             Sound:Play() --Playing one of the best Queen songs ever aside from Bohemian Rhapsody, Bicycle and Another One Bites the Dust
  80. end)
Add Comment
Please, Sign In to add comment