Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local DataStoreService = game:GetService("DataStoreService")
- local EffectsDatastore = DataStoreService:GetDataStore("EffectsDatastore")
- game.Players.PlayerAdded:Connect(function(Player)
- local EffectsFolder = Instance.new("Folder",Player)
- EffectsFolder.Name = "EffectsFolder"
- local EquippedDeathSounds = Instance.new("StringValue",Player)
- EquippedDeathSounds.Name = "EquippedDeathSounds"
- -- Bool
- local EffectsBool = Instance.new("BoolValue",EffectsFolder)
- EffectsBool.Name = "EffectsBool"
- -- Hand Trails
- local White_Trail = Instance.new("BoolValue",EffectsFolder)
- White_Trail.Name = "White Trail"
- local userId = Player.UserId
- local key = "Player_"..userId
- local success, returnValue
- success, returnValue = pcall(EffectsDatastore.GetAsync, EffectsDatastore, key)
- if success then
- if returnValue == nil then
- returnValue = {
- White_Trail = false,
- EquippedDeathSounds = ""
- }
- end
- -- Safety Bool
- EffectsBool.Value = true
- -- Trails
- White_Trail.Value = if returnValue.White_Trail ~= nil then returnValue.White_Trail else false
- -- Equppables
- EquippedDeathSounds.Value = if returnValue.EquippedDeathSounds ~= nil then returnValue.EquippedDeathSounds else ""
- else
- Player:Kick("There was an error with loading your Data! Roblox's Datastore might be down,try agen later or contact us trough our Group!")
- print(Player.Name.. " Has a Data loading ERROR!!")
- end
- end)
- game.Players.PlayerRemoving:Connect(function(Player)
- if Player.EffectsFolder:FindFirstChild("EffectsBool").Value == true then
- local userId = Player.UserId
- local key = "Player_"..userId
- -- Main Values
- local equippeddeathsounds = Player.EquippedDeathSounds.Value
- -- Hand Trails
- local white_trail = Player.EffectsFolder["White Trail"].Value
- local DataTable = {
- EquippedDeathSounds = equippeddeathsounds,
- White_Trail = white_trail,
- }
- print(DataTable)
- local success,returnValue
- success,returnValue = pcall(EffectsDatastore.UpdateAsync, EffectsDatastore, key, function()
- return DataTable
- end)
- if success then
- print("Effects Data Saved!")
- else
- print("Data Saving ERROR!!")
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement