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

Why isn't my data store loading the items and cloning them to the player?

Asked by 6 years ago

why isn't my data store working? please help me.

local xs= game:GetService('DataStoreService'):GetDataStore('Test01')
local at = {}
local Players = game.Players
local plr = game.Players.LocalPlayer
local ss = game:GetService('ServerStorage')
local rs = game:GetService('ReplicatedStorage')
local done = rs.avatareditor.done

local plr = game.Players.LocalPlayer



Players.PlayerAdded:Connect(function(plr)
local zs= xs:GetAsync("BOBBY"..plr.UserId)
    at[plr] = {}
    at[plr].zs = {}
    if zs then


            at[plr].zs = zs
    print("waaa")

    for i,v in pairs(at[plr].zs.Hair) do
wait(5)
print(">:v")

    ss:WaitForChild('Hairs'):FindFirstChild(v):Clone().Parent = plr.Character
  end
           for i,v in pairs(at[plr].zs.Hats) do

            ss:WaitForChild('Hats'):FindFirstChild(v):Clone().Parent = plr.Character
  end
            for i, v in pairs(at[plr].zs.Shirt) do
    plr.Character:FindFirstChild('Shirt').ShirtTemplate = v
  end
            for i, v in pairs(at[plr].zs.Pants) do
    plr.Character:FindFirstChild('Pants').PantsTemplate = v
  end
            for i, v in pairs(at[plr].zs.Face) do
    plr.Character.Head.face = v
  end

    print("did it work")




    else
        print("crap")
        at[plr].zs.Hair = {}
        at[plr].zs.Hats = {}
        at[plr].zs.Shirt = {}
        at[plr].zs.Pants = {}
        at[plr].zs.Face = {}
        xs:SetAsync("BOBBY"..plr.UserId,at[plr].zs)
    end
end)








done.OnServerEvent:connect(function(plr)

for i,v in pairs (plr.Character:GetChildren()) do
    table.insert(at[plr].zs.Face,v.Parent.Head.face.Texture)
    if v:IsA("Hat")and v.Name == "Hat"..i then
        table.insert(at[plr].zs.Hats,v.Name)

        if v:IsA("Hat")and v.Name == "Hair"..i then
        table.insert(at[plr].zs.Hairs,v.Name)


        if v:IsA("Shirt") then
            table.insert(at[plr].zs.Shirt,v.ShirtTemplate)

        if v:IsA("Pants") then
            table.insert(at[plr].zs.Pants,v.PantsTemplate)

        xs:SetAsync("BOBBY"..plr.UserId,at[plr].zs)

        end
        end
        end
    end
end
end)









Answer this question