Advertisement
qsenko1

Use This

Jun 2nd, 2024
825
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.20 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local DataStoreService = game:GetService("DataStoreService")
  3. local EffectsDatastore = DataStoreService:GetDataStore("EffectsDatastore")
  4.  
  5. game.Players.PlayerAdded:Connect(function(Player)  
  6.     local EffectsFolder = Instance.new("Folder",Player)
  7.     EffectsFolder.Name = "EffectsFolder"
  8.     local EquippedDeathSounds = Instance.new("StringValue",Player)
  9.     EquippedDeathSounds.Name = "EquippedDeathSounds"
  10.     -- Bool
  11.     local EffectsBool = Instance.new("BoolValue",EffectsFolder)
  12.     EffectsBool.Name = "EffectsBool"
  13.     -- Hand Trails
  14.     local White_Trail = Instance.new("BoolValue",EffectsFolder)
  15.     White_Trail.Name = "White Trail"
  16.  
  17.     local userId = Player.UserId
  18.     local key = "Player_"..userId
  19.  
  20.     local success, returnValue
  21.     success, returnValue = pcall(EffectsDatastore.GetAsync, EffectsDatastore, key)
  22.  
  23.     if success then
  24.         if returnValue == nil then
  25.             returnValue = {
  26.                 White_Trail = false,
  27.                 EquippedDeathSounds = ""
  28.             }          
  29.         end
  30.         -- Safety Bool
  31.         EffectsBool.Value = true
  32.         -- Trails
  33.         White_Trail.Value = if returnValue.White_Trail ~= nil then returnValue.White_Trail else false
  34.         -- Equppables
  35.         EquippedDeathSounds.Value = if returnValue.EquippedDeathSounds ~= nil then returnValue.EquippedDeathSounds else ""
  36.     else
  37.         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!")
  38.         print(Player.Name.. " Has a Data loading ERROR!!")
  39.     end
  40.  
  41. end)
  42.  
  43. game.Players.PlayerRemoving:Connect(function(Player)
  44.     if Player.EffectsFolder:FindFirstChild("EffectsBool").Value == true then
  45.         local userId = Player.UserId
  46.         local key = "Player_"..userId
  47.         -- Main Values
  48.         local equippeddeathsounds = Player.EquippedDeathSounds.Value
  49.         -- Hand Trails
  50.         local white_trail = Player.EffectsFolder["White Trail"].Value
  51.  
  52.         local DataTable = {
  53.             EquippedDeathSounds = equippeddeathsounds,
  54.             White_Trail = white_trail,
  55.         }
  56.  
  57.         print(DataTable)
  58.  
  59.         local success,returnValue
  60.         success,returnValue = pcall(EffectsDatastore.UpdateAsync, EffectsDatastore, key, function()
  61.             return DataTable
  62.         end)
  63.  
  64.         if success  then
  65.             print("Effects Data Saved!")
  66.         else
  67.             print("Data Saving ERROR!!")
  68.         end
  69.  
  70.     end
  71. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement