4bcuy

hd 3

May 1st, 2023
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. local DataStoreService = game:GetService("DataStoreService")
  2. local playerData = DataStoreService:GetDataStore("PlayerData")
  3.  
  4. local function onPlayerJoin(Player)
  5. local BlackMarketThings = Instance.new("Folder")
  6. BlackMarketThings.Name = "BlackMarketThings"
  7. BlackMarketThings.Parent = Player
  8.  
  9. local SpeedCheck = Instance.new("BoolValue")
  10. SpeedCheck.Name = "SpeedCheck"
  11. SpeedCheck.Parent = BlackMarketThings
  12. SpeedCheck.Value = false
  13.  
  14. local HealthCheck = Instance.new("BoolValue")
  15. HealthCheck.Name = "HealthCheck"
  16. HealthCheck.Parent = BlackMarketThings
  17. HealthCheck.Value = false
  18.  
  19. local playerUserId = "Player_ ".. Player.UserId
  20. local GetData
  21. local Success, Error = pcall(function()
  22. GetData = playerData:GetAsync(playerUserId)
  23. end)
  24.  
  25. if Success and GetData then
  26. SpeedCheck.Value = GetData[1]
  27. else
  28. SpeedCheck.Value = false
  29. end
  30. end
  31.  
  32. local function onPlayerLeave(Player)
  33. local success, err = pcall(function()
  34. local playerUserId = "Player_ "..Player.UserId
  35. local speedCheckValue = Player.BlackMarketThings.SpeedCheck
  36.  
  37. playerData:SetAsync(playerUserId, {
  38. speedCheckValue.Value
  39. })
  40.  
  41. end)
  42. if not success then
  43. warn("Could not save data, Error message: ", err)
  44. else
  45. print("Saved 2")
  46. end
  47. end
  48.  
  49. game.Players.PlayerAdded:Connect(onPlayerJoin)
  50. game.Players.PlayerRemoving:Connect(onPlayerLeave)
Advertisement
Add Comment
Please, Sign In to add comment