Weird problem. My Backpack is only saving 7 items now. Anything purchased after that disappears after the player dies. The only thing I've changed recently is turning on Filtering Enabled. Did turning this on break my Data Store script? If so, how do I fix it?
Here's my script below:
--Setup the DataStore local ds = game:GetService("DataStoreService"):GetDataStore("REMOVED"); local tools = game.ServerStorage.ToolStorage; --Specify all possible tools --{[Check and Load]} game.Players.PlayerAdded:connect(function(plr) --Retrieve the potential data local data = false print("DataStoreBackSave1") plr.CharacterAdded:connect(function(char) -- this will run everytime the Player's Character has been added in workspace. if not data then data = ds:GetAsync(plr.UserId); end if data then --If it does, loop and clone respective tools. for _,v in next,data do local tool = tools:FindFirstChild(v); if tool then tool:Clone().Parent = plr.Backpack; end end end end) end) --{[Collect and Save]} game.Players.PlayerRemoving:connect(function(plr) --Make a table to hold all the data local toolList = {}; --Iterate through the backpack and fill the table in for _,v in next,plr.Backpack:GetChildren() do --Make sure it's actually a tool if v:IsA("Tool") or v:IsA("HopperBin") then toolList[#toolList+1] = v.Name; end end --Save the table ds:SetAsync(plr.UserId,toolList); end) print("DataStoreBackSave2")
Yes, since its filtering enabled, when the player's data changes its only doing it for the client not the server. So u need to add remote events/functions to make it work.