Hello, I’ve gotten a datastore working for my game with there being boolean and number values within the profile, but there’s an issue when it comes to tables within the profile. If I try accessing a table from the profile it returns as nil, but with other values such as numbervalues or boolvalues it works just fine.
Here’s the profile template (it’s inside of a module script called MenuDataManager and it loads the profile for the next script to use with MenuDataManager:Get(player)):
local profiletemplate = {
ResetDelay = 5;
KeyDisplayLimit = 5;
ShowTimer = true;
MuteBoomboxes = false;
HidePlayers = 1;
HideCosmetics = false;
Cosmetics = {};
}
And here’s the script that tries accessing the table:
for i, v in pairs(gui.Main.TabsFrame.Tabs.Cosmetics:GetDescendants()) do --cosmetics
if v:IsA("ValueBase") and v.Name == "Equipped" then
local cosmeticstable = data.Cosmetics
local test = data.ResetDelay
print(test, cosmeticstable)
if cosmeticstable[v.Parent.Name] then
v.Value = true
end
event.OnServerEvent:Connect(function(plr, w, x)
if x == true then
table.insert(cosmeticstable, w.Parent.Name)
print("added " ..w.Parent.Name.. " to table of equipped cosmetics")
elseif x == false then
table.remove(cosmeticstable, w.Parent.Name)
print("removed " ..w.Parent.Name.. " to table of equipped cosmetics")
end
end)
end
end
the print(test, cosmeticstable) prints out this: 3, nil
the 3 could be a value between 1 and 6 btw