Ok so the idea here is to save these values, as shown in the following picture:
(What I want to save is the value of Optic, Barrel, etc. Each subfolder has these exact 4 string value copies, and the subfolder is the name of the tool.)
So far, I have began writing this code after some research on this, but could not find a solution.
local dsService = game:GetService("DataStoreService")
local ds = dsService:GetDataStore("Attachments")
game.Players.PlayerAdded:Connect(function(plr)
local guns = Instance.new("Folder",plr)
guns.Name = "WeaponAttachments"
wait(4)
for i,v in pairs(plr.Backpack:GetChildren()) do
-- print(v.Nlame)
local weapon = Instance.new("Folder",guns)
weapon.Name = v.Name
local at1 = Instance.new("StringValue", weapon)
at1.Name = "Optic"
local at2 = Instance.new("StringValue", weapon)
at2.Name = "Barrel"
local at3 = Instance.new("StringValue", weapon)
at3.Name = "UnderBarrel"
local at4 = Instance.new("StringValue", weapon)
at4.Name = "Other"
end
wait(1)
--The stuff prior to this is how I got the folders shown in the script.
local atts = {}
atts.insert(plr:WaitForChild("WeaponAttachments"))
local data = {}
for i, v in pairs(guns:GetChildren()) do
data[v.Name] = {}
for i,g in pairs(v:GetChildren()) do
data.insert(v.Name, g)
end
end
print(atts)
end)
When I try to see the table with print, however, it states this:
Any help? I have been working on this for an hour and can’t fix it.