Advertisement
minimic2002

Roblox DataStore Script

Aug 29th, 2020
2,284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. --- minimic2002's DataStore Script
  2.  
  3. local DataStoreService = game:GetService("DataStoreService")
  4.  
  5. function SetData(Store,Player,Data)
  6. local NewStore = DataStoreService:GetDataStore(Store)
  7. NewStore:SetAsync(Player,Data)
  8. end
  9.  
  10. function UpData(Store,Player,Data)
  11. local NewStore = DataStoreService:GetDataStore(Store)
  12. NewStore:UpdateAsync(Player,Data)
  13. end
  14.  
  15. function GetData(Store,Player)
  16. local NewStore = DataStoreService:GetDataStore(Store)
  17. local Result = NewStore:GetAsync(Player)
  18. return Result
  19. end
  20.  
  21. function RemoveData(Store,Player)
  22. local NewStore = DataStoreService:GetDataStore(Store)
  23. NewStore:SetAsync(Player,nil)
  24. end
  25.  
  26. function CheckForExistingData(Store,Player)
  27. local Data = GetData(Store,Player)
  28. if Data == nil then
  29. local Result = false
  30. return Result
  31. else
  32. local Result = true
  33. return Result
  34. end
  35. end
  36.  
  37. function CreateListing(Store,Data)
  38. local EntryCount = GetData(Store .. "EntryCount","EntryCount")
  39. if tonumber(EntryCount) == nil then
  40. EntryCount = 0
  41. end
  42. EntryCount = tostring(tonumber(EntryCount) + 1)
  43. SetData(Store,EntryCount,Data)
  44. SetData(Store .. "EntryCount","EntryCount",EntryCount)
  45. end
  46.  
  47. function GetListings(Store)
  48. local EntryCount = GetData(Store .. "EntryCount","EntryCount")
  49. EntryCount = tonumber(EntryCount)
  50. local StoreNames = {}
  51. for i = 1, EntryCount do
  52. local Name = tostring(i)
  53. local Check = CheckForExistingData(Store,tostring(i))
  54. if Check == true then
  55. table.insert(StoreNames,Name)
  56. end
  57. end
  58. return StoreNames
  59. end
  60.  
  61. function RemoveListing(Store,Number)
  62. local EntryCount = GetData(Store .. "EntryCount","EntryCount")
  63. local NewStore = DataStoreService:GetDataStore(Store)
  64. NewStore:SetAsync(Number,nil)
  65. end
  66.  
  67. function GetEntryCount(Store)
  68. local EntryCount = GetData(Store .. "EntryCount","EntryCount")
  69. EntryCount = tonumber(EntryCount)
  70. return EntryCount
  71. end
  72.  
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement