qsenko1

DataStore Test

Jul 23rd, 2021
1,146
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. game.Players.PlayerAdded:Connect(function(player)
  2.     --Pets stuff
  3.     local PetsFolder = Instance.new("Folder",player); PetsFolder.Name = "PetsFolder"
  4.     local Pets = Instance.new("Folder",PetsFolder); Pets.Name = "Pets"
  5.     local PetsValues = Instance.new("Folder",PetsFolder); PetsValues.Name = "Values"
  6.     local PetNameCheck = Instance.new("StringValue",PetsFolder); PetNameCheck.Name = "PetNameCheck"
  7.     --Pets Values
  8.     local Turtle = Instance.new("BoolValue",PetsValues); Turtle.Name = "Turtle"
  9.     local Bunny = Instance.new("BoolValue",PetsValues); Bunny.Name = "Bunny"
  10.     local Parrot = Instance.new("BoolValue",PetsValues); Parrot.Name = "Parrot"
  11.     local PiggyBank = Instance.new("BoolValue",PetsValues); PiggyBank.Name = "Piggy Bank"
  12.     local MrCrab = Instance.new("BoolValue",PetsValues); MrCrab.Name = "Mr.Crab"
  13.     local PufferFish = Instance.new("BoolValue",PetsValues); PufferFish.Name = "Puffer Fish"
  14.     local Hedgehog = Instance.new("BoolValue",PetsValues); Hedgehog.Name = "Hedgehog"
  15.     local CrocodilePal = Instance.new("BoolValue",PetsValues); CrocodilePal.Name = "CrocodilePal"
  16.     local KingFrog = Instance.new("BoolValue",PetsValues); KingFrog.Name = "King Frog"
  17.     local Kitty = Instance.new("BoolValue",PetsValues); Kitty.Name = "Kitty"
  18.     local EpicDuck = Instance.new("BoolValue",PetsValues); EpicDuck.Name = "Epic Duck"
  19.     local Octopus = Instance.new("BoolValue",PetsValues); Octopus.Name = "Octopus"
  20.     local PetRock = Instance.new("BoolValue",PetsValues); PetRock.Name = "Pet Rock"
  21.     local SeaMonster = Instance.new("BoolValue",PetsValues); SeaMonster.Name = "Sea Monster"
  22.     local Pikachu = Instance.new("BoolValue",PetsValues); Pikachu.Name = "Pikachu"
  23.     local OOFSpider = Instance.new("BoolValue",PetsValues); OOFSpider.Name = "OOF Spider"
  24.     local PetGojira = Instance.new("BoolValue",PetsValues); PetGojira.Name = "Pet Gojira"
  25.     local Scorpion = Instance.new("BoolValue",PetsValues); Scorpion.Name = "Scorpion"
  26.     local HungryShark = Instance.new("BoolValue",PetsValues); HungryShark.Name = "Hungry Shark"
  27.     local AnnoyingOrange = Instance.new("BoolValue",PetsValues); AnnoyingOrange.Name = "Annoying Orange"
  28.     local EvilUnicorn = Instance.new("BoolValue",PetsValues); EvilUnicorn.Name = "Evil Unicorn"
  29.     local ArcticReindeer = Instance.new("BoolValue",PetsValues); ArcticReindeer.Name = "Arctic Reindeer"
  30.     local Bird = Instance.new("BoolValue",PetsValues); Bird.Name = "Bird"
  31.     local GrayWolf = Instance.new("BoolValue",PetsValues); GrayWolf.Name = "Gray Wolf"
  32.     local Dog = Instance.new("BoolValue",PetsValues); Dog.Name = "Dog"
  33.     local Otter = Instance.new("BoolValue",PetsValues); Otter.Name = "Otter"
  34.     local AlienBee = Instance.new("BoolValue",PetsValues); AlienBee.Name = "Alien Bee"
  35.     local TRex = Instance.new("BoolValue",PetsValues); TRex.Name = "T-Rex"
  36.     local Phoenix = Instance.new("BoolValue",PetsValues); Phoenix.Name = "Phoenix"
  37.     local HellDragon = Instance.new("BoolValue",PetsValues); HellDragon.Name = "Hell Dragon"
  38.     --Hidden Pet Value
  39.     local HiddenPetValue = Instance.new("BoolValue",PetsValues); HiddenPetValue.Name = "Eye of Cthulhu"
  40.    
  41.     -- Data Load
  42.     local PlayerKey = string.format("%d_PETSDATA,", player.UserId);
  43.     local GotData, DataReturn = pcall(Petsdata.GetAsync, Petsdata , PlayerKey)
  44.  
  45.     if (GotData and DataReturn ~= nil)then
  46.         PetNameCheck.Value = DataReturn;
  47.         Turtle.Value = DataReturn;
  48.         Bunny.Value = DataReturn;
  49.         Parrot.Value = DataReturn;
  50.         PiggyBank.Value = DataReturn;
  51.         MrCrab.Value = DataReturn;
  52.         PufferFish.Value = DataReturn;
  53.         Hedgehog.Value = DataReturn;
  54.         CrocodilePal.Value = DataReturn;
  55.         KingFrog.Value = DataReturn;
  56.         Kitty.Value = DataReturn;
  57.         EpicDuck.Value = DataReturn;
  58.         Octopus.Value = DataReturn;
  59.         PetRock.Value = DataReturn;
  60.         SeaMonster.Value = DataReturn;
  61.         Pikachu.Value = DataReturn;
  62.         OOFSpider.Value = DataReturn;
  63.         PetGojira.Value = DataReturn;
  64.         Scorpion.Value = DataReturn;
  65.         HungryShark.Value = DataReturn;
  66.         AnnoyingOrange.Value = DataReturn;
  67.         EvilUnicorn.Value = DataReturn;
  68.         ArcticReindeer.Value = DataReturn;
  69.         Bird.Value = DataReturn;
  70.         GrayWolf.Value = DataReturn;
  71.         Dog.Value = DataReturn;
  72.         Otter.Value = DataReturn;
  73.         AlienBee.Value = DataReturn;
  74.         TRex.Value = DataReturn;
  75.         Phoenix.Value = DataReturn;
  76.         HellDragon.Value = DataReturn;
  77.         HiddenPetValue.Value = DataReturn
  78.     end
  79.        
  80.      game.Players.PlayerRemoving:Connect(function(player)
  81.    
  82.     local PlayerKey = string.format("%d_PETSDATA,", player.UserId);
  83.     local data = {
  84.         PetNameCheck = player.PetsFolder.PetNameCheck.Value;
  85.         Turtle = player.PetsFolder.PetsValues.Turtle.Value;
  86.         Bunny = player.PetsFolder.PetsValues.Bunny.Value
  87.     }
  88.    
  89.     local Success = false
  90.    
  91.     if (not Success) then
  92.         Success = pcall(Petsdata.SetAsync, Petsdata , PlayerKey, data)
  93.     end
  94.    
  95. end)
  96.        
  97.        
RAW Paste Data