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

Datastore breaking with no errors?

Asked by
Edcorp 10
8 years ago

So I'm trying to save the player's stats and their parts in game. Alone the part saving works but when I added the stat saving it broke and didn't run the part saving.

local PartStoring = game:GetService("DataStoreService"):GetDataStore("BetaParts")
local StatStoring = game:GetService("DataStoreService"):GetDataStore("BetaStats")

--//Variables
local placingStorage = game.ServerStorage.PlaceableParts

--//Tables
local statHolder = {}

game.Players.PlayerRemoving:connect(function(player)
    if game.Workspace:FindFirstChild(player.Name.."'sItems") then

        print('hello is me fruim d a uder si de') --Prints

        local key = "user_"..player.userId

        --Stats Storing
        local Stats
        for k,l in pairs (statHolder) do
            if l[1] == player.Name and l[2] then
                Stats = l
            end
        end
        print('mid check') --Prints
        if Stats then
            StatStoring:SetAsync(key,Stats[2])
            table.remove(Stats)
        end
        --Part Storing
        print('saving parts') --Doesn't print

        local model = game.Workspace[player.Name.."'sItems"]
        local FinalString = {}

        for i,v in pairs (model:GetChildren()) do
            x,y,z,rx,ry,rz = v.PrimaryPart.CFrame.X, v.PrimaryPart.CFrame.Y, v.PrimaryPart.CFrame.Z, v.PrimaryPart.CFrame:toEulerAnglesXYZ()
            local comp = {x,y,z,rx,ry,rz}
            local everything = {v.Name,comp}
            if model:FindFirstChild("Settings") then
                for k,l in pairs (model.Settings:GetChildren()) do
                    table.insert(everything,10000,l.Name)
                    table.insert(everything,10000,l.Value)
                end
            end
            table.insert(FinalString,everything)
        end

        if #FinalString >= 1 then
            print('saved') --of course doesn't print
            PartStoring:SetAsync(key, FinalString)
        end
    end
end)
0
Perhaps SetAsync is hanging. But that's odd, because it's supposed to be async... iconmaster 301 — 8y
0
The weird thing is that I'm not really new to DataStores at all, this is just random. Edcorp 10 — 8y

Answer this question