Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DS = game:GetService('DataStoreService')
- local SS = game:GetService('ServerStorage')
- local tableData = DS:GetDataStore('Stats')
- local LS = SS:WaitForChild('LvlStats')
- local startData = {
- Lvl = 1, XP = 0, MXP = 500
- } --Table for Data
- game.Players.PlayerAdded:Connect(function(plr) --Function will run when a player joins
- local stFolder = Instance.new('Folder') --Creating a new folder and setting the player that joins as its parent
- stFolder.Name = "Stats"
- stFolder.Parent = plr
- local Data
- Data = tableData:GetAsync(plr.userId) --Acquiring Data
- for i,v in pairs(startData) do --Indexing startData table
- if type(v) == 'number' then -- If the table cotains a value that is a number it will create an interger
- local Num = Instance.new('IntValue')
- Num.Name = i
- Num.Value = v
- Num.Parent = stFolder
- elseif type(v) == 'boolean' then -- If its a true or false value it will create a boolvalue
- local Bool = Instance.new('BoolValue')
- Bool.Name = i
- Bool.Value = v
- Bool.Parent = stFolder
- elseif type(v) == 'string' then -- If its letters or anything in quotation marks it will create a string value
- local Ito = Instance.new('StringValue')
- Ito.Name = i
- Ito.Value = v
- Ito.Parent = stFolder
- end
- end
- if Data then --Checking if getting data with GetAsync() did not return a nil value
- 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
- plr.Stats[i].Value = v
- end
- end
- plr.Stats.XP.Changed:Connect(function(plr) --Simple level up system, this function will activate whenever the xp value is changed
- if plr.Stats.XP.Value >= plr.Stats.MXP.Value then --Checking if the xp value is higher than max xp value
- plr.Stats.XP.Value = plr.Stats.XP.Value - plr.Stats.MXP.Value
- plr.Stats.MXP.Value = plr.Stats.MXP.Value * 1.25 --Adding 1 lvl and multiplying the max xp value by 1.25
- plr.Stats.Lvl.Value = plr.Stats.Lvl.Value + 1
- end
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(plr) --function will run upon a player leaves the game
- local Data = {} --creating a table without any values atm
- for i,v in pairs(plr.Stats:GetChildren()) do --indexing the stats folder on the player that left
- Data[v.Name] = v.Value --creating the values that was in the stats folder into the table
- end
- tableData:SetAsync(plr.userId, Data) --saving the table in datastore
- end)
- ----------------------------
- game.Players.PlayerAdded:Connect(function(plr) --Waiting for a player to join event
- local char = plr.Character or plr.CharacterAdded:Wait() -- Getting the player's character
- for i,v in pairs(char:GetChildren()) do --looping through the character only finding all r15 parts except for the head
- if v:IsA('MeshPart') then
- v.Transparency = 1
- local BV = Instance.new('BodyVelocity') --Setting transparency to 1 making floating head
- BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
- 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.]]
- --[[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]]
- BV.Parent = plr.Character.HumanoidRootPart
- end
- end
- local Sound = Instance.new('Sound') --creating a sound and setting it to where the player can hear
- Sound.SoundId = 'rbxassetid://3455283612' --Don't Stop Me Now by Queen
- Sound.Parent = plr.Character.Head
- if not Sound.IsLoaded then --waiting for the song to fully load
- Sound.Loaded:Wait()
- end
- Sound.TimePosition = 28.5
- Sound:Play() --Playing one of the best Queen songs ever aside from Bohemian Rhapsody, Bicycle and Another One Bites the Dust
- end)
Add Comment
Please, Sign In to add comment