Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Did Filtering Enabled Break my DataStore?

Asked by 6 years ago
Edited 6 years ago

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")
0
A data store is server side only so FE will not effect it in any way but FE may effect how the save process can be triggered and may require the use of a remote event. User#5423 17 — 6y

1 answer

Log in to vote
0
Answered by
oSyM8V3N 429 Moderation Voter
6 years ago

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.

0
Thanks for the confirmation! I confess, I'm not sure how to do that. I never worked with remote events. Can you help me out a bit with this? :) Thank you again. Never2Humble 90 — 6y
0
I would love to, but i am having problems with it myself. But if i do find a breakthrough, i'll be sure to let you know :) oSyM8V3N 429 — 6y
0
A data store will only work on the server side, It is not effected by FE. User#5423 17 — 6y
0
Look on the wiki. hiimgoodpack 2009 — 6y
View all comments (2 more)
0
I've looked on the wiki, and didn't understand how to use them. =/ Remote Events confuse me. Never2Humble 90 — 6y
0
Check out a video on youtube about Filtering Enabled by 'PeasFactory", he's the one who taught me to use em. And +kingdom5, if you want to change the clients value's through a localscript you need to use Remote Events oSyM8V3N 429 — 6y
Ad

Answer this question