Sungmingamerpro13

Scrapped Content DataStore

Sep 2nd, 2026 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.92 KB | None | 0 0
  1. local TeleportService = game:GetService("TeleportService")
  2. local scrappedContentDataStore = game:GetService("DataStoreService"):GetDataStore("scrappedContent")
  3.  
  4. local stringValue = ""
  5.  
  6. game.Players.PlayerAdded:Connect(function(player)
  7.    
  8.     local scrappedContentValue = Instance.new("StringValue", player)
  9.     scrappedContentValue.Name = "ScrappedContent"
  10.    
  11.     local success, Data = pcall(function()
  12.         return scrappedContentDataStore:GetAsync(player.UserId)
  13.     end)
  14.    
  15.     if success and Data then
  16.         scrappedContentValue.Value = Data.ScrappedContent or ""
  17.     else
  18.         scrappedContentValue.Value = stringValue
  19.     end
  20. end)
  21.  
  22. game.Players.PlayerRemoving:Connect(function(player)
  23.    
  24.     local scrappedContentValue = player:FindFirstChild("ScrappedContent")
  25.    
  26.     if scrappedContentValue then
  27.        
  28.         pcall(function()
  29.             scrappedContentDataStore:SetAsync(player.UserId, {
  30.                 ScrappedContent = scrappedContentValue.Value
  31.             })
  32.         end)
  33.     end
  34. end)
  35.  
Advertisement
Add Comment
Please, Sign In to add comment