Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// Services
- local DataService = {}
- local ServerStorage = game:GetService("ServerStorage")
- local ProfileService = require(ServerStorage.ProfileService)
- --// Globals
- local DefaultData = {
- Coins = 0;
- Inventory = {};
- }
- local ProfileStore = ProfileService.GetProfileStore("ProfileStore", DefaultData)
- DataService.LoadedProfiles = {}
- --// Core
- function DataService.Welcome(Player)
- print("Loaded Player")
- end
- function DataService.HandleClient(Player)
- local Profile = ProfileStore:LoadProfileAsync(tostring(Player.UserId))
- if Profile then
- Profile:AddUserId(Player.UserId)
- Profile:Reconcile()
- Profile:ListenToRelease(function()
- DataService.LoadedProfiles[Player] = nil
- end)
- if Player:IsDescendantOf(game.Players) then
- DataService.LoadedProfiles[Player] = Profile
- DataService.Welcome(Player)
- else
- Profile:Release()
- end
- else
- Player:Kick("Data failed to load!")
- end
- end
- function DataService.HandleRemovingClient(Player)
- local Profile = DataService.LoadedProfiles[Player]
- if Profile then
- Profile:Release()
- end
- end
- return DataService
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement