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

Why datastore can't get the value?

Asked by 4 years ago

Anyone know why it it can't get the value of toolsdata[v.Name]?

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:wait()
    local keyId = plr.UserId.."-Tools"


    local tooldata = toolsDataStore:GetAsync(keyId)
    if tooldata then
        print("found data")
        for i,v in pairs(serverStorage:GetChildren()) do
            print(v.Name)
            print(tooldata[v.Name]) -- prints nil
            if v.Name == tooldata[v.Name] then
                wait(0.5)
                print(v.Name.." is the same as "..tooldata[i])
                local tool = v:Clone()
                tool.Parent = plr.Backpack
            end
        end
    end


end)
0
I would also like to add that it works if i put in the index instead of v so for example tooldata[i], but comparing that to v.Name doesn't get the result I want. RBLX_Nat 18 — 4y

Answer this question