Advertisement
Sungmingamerpro13

New DataStore Shirt and Pants

Aug 26th, 2023
1,252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.94 KB | None | 0 0
  1. local DataStore = game:GetService(“DataStoreService”):GetDataStore(“ClothingSave”)
  2. function Save(Chr, Plr)
  3.  
  4. local face
  5. for i,v in pairs(Chr.Head:GetChildren()) do
  6.     if v:IsA("Decal") then
  7.         face = v
  8.     end
  9. end
  10. local information = {
  11.     ["Shirt"] = Chr.Shirt.ShirtTemplate;
  12.     ["Pants"] = Chr.Pants.PantsTemplate;
  13.     ["Face"] =face.Texture
  14. }
  15. DataStore:SetAsync(Plr.UserId, information)
  16. end
  17.  
  18. function Load(Chr, Plr)
  19.     local good, info = pcall(function()
  20.         return(DataStore:GetAsync(Plr.UserId))
  21.     end)
  22.     print(Plr.Name, "DataStoreRetrivalInformation", good, info)
  23.     for i,v in pairs(Chr.Head:GetChildren()) do
  24.         if v:IsA("Decal") then
  25.             v.Texture = info.Face
  26.         end
  27.     end    
  28.     Chr.Shirt.ShirtTemplate = info.Shirt
  29.     Chr.Pants.PantsTemplate = info.Pants
  30. end
  31. game.Players.PlayerAdded:Connect(function(Plr)
  32.     local Char = Plr.CharacterAppearanceLoaded:Wait()
  33.     Load(Char)
  34. end)
  35. game.Players.PlayerRemoving:Connect(function(Plr)
  36.     Save()
  37. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement