--Services local RStorage = game:GetService("ReplicatedStorage") local SPlayers = game:GetService("Players") --Modules local ProfileStore = require(script.Parent.ProfileStore) local KitSettings = require(RStorage.Info.KitSettings) --Remotes local DataManager = {} DataManager.Template = { Weapon = "StarFall"; WeaponsOwned = { "Pin"; "Rose"; "Crayon"; "Soul Collector"; "NightFall"; "StarFall"; }; Balloon = "Monkey"; BalloonsOwned = { "Default"; "Ninja"; "Bubble"; "Lightning"; "Monkey"; }; Coins = 0; } DataManager.Profiles = {} DataManager.PlayerStore = nil function DataManager.OnStart() DataManager.PlayerStore = ProfileStore.New("PopDataStore", DataManager.Template) SPlayers.PlayerRemoving:Connect(function(player) local profile = DataManager.Profiles[player] if profile ~= nil then profile:EndSession() end end) end function DataManager.PlayerValuesUpdate(Plr, NoReset) for i,v in DataManager.Profiles[Plr].Data do if Plr:FindFirstChild(i) then print(Plr[i]) Plr[i].Value = DataManager.Profiles[Plr].Data[i] end if type(v) == "table" then local Folder = Instance.new("Folder") Folder.Parent = Plr Folder.Name = i print(v) for x,y in v do print(x,y,v) local Value = Instance.new("StringValue") Value.Parent = Folder Value.Value = y end end end if not NoReset then Plr:LoadCharacter() end end function DataManager.UpdateMovementSettings(Plr) local BalloonType = Plr.Balloon.Value if not Plr:FindFirstChild("PlayerInfo") then local PlayerInfo = Instance.new("Folder"); PlayerInfo.Parent = Plr; PlayerInfo.Name = "PlayerInfo" local Settings = Instance.new("Folder"); Settings.Parent = PlayerInfo; Settings.Name = "Settings" local JumpCount = Instance.new("NumberValue"); JumpCount.Parent = Settings; JumpCount.Name = "JumpCount" local WalkSpeed = Instance.new("NumberValue"); WalkSpeed.Parent = Settings; WalkSpeed.Name = "WalkSpeed" local SlideLength = Instance.new("NumberValue"); SlideLength.Parent = Settings; SlideLength.Name = "SlideLength" local RunSpeed = Instance.new("NumberValue"); RunSpeed.Parent = Settings; RunSpeed.Name = "RunSpeed" end local Settings = Plr.PlayerInfo.Settings for i,v in Settings:GetChildren() do if KitSettings.PlayerSettings[BalloonType] then v.Value = KitSettings.PlayerSettings[BalloonType][v.Name] else v.Value = KitSettings.PlayerSettings.Nan[v.Name] end end end function DataManager.OnPlayerAdded(Plr) local profile = DataManager.PlayerStore:StartSessionAsync(`{Plr.UserId}_Data`, { Cancel = function() return Plr.Parent ~= SPlayers end, }) print(profile) profile.Data = {} -- Remove this line for data store to work if profile ~= nil then profile:AddUserId(Plr.UserId) -- GDPR compliance profile:Reconcile() -- Fill in missing variables from PROFILE_TEMPLATE (optional) profile.OnSessionEnd:Connect(function() DataManager.Profiles[Plr] = nil Plr:Kick(`Profile session end - Please rejoin`) end) if Plr.Parent == SPlayers then DataManager.Profiles[Plr] = profile print(`Profile loaded for {Plr.DisplayName}!`) else profile:EndSession() end else Plr:Kick(`Profile load fail - Please rejoin`) end print("Profile loaded") if not RStorage.KITS.Balloons:FindFirstChild(profile.Data.Balloon) then profile.Data.Balloon = "Default" end if not RStorage.KITS.Weapons:FindFirstChild(profile.Data.Weapon) then profile.Data.Weapon = "Pin" end DataManager.PlayerValuesUpdate(Plr) DataManager.UpdateMovementSettings(Plr) end return DataManager