Hi, I've been asking this question for 4 times and this is the 5th one so please help me. So basically I added bool values to the folder so I could access the players inventory later in the game and the problem is that it isn't saving.
Datastore2 script:
local DataStore2 = require(1936396537)
local default = {"Wooden Sword","Wooden Bow","Wooden Spear"}
game.Players.PlayerAdded:Connect(function(plr)
local dataweap = DataStore2("Weapons",plr)
local fol = Instance.new("Folder")
fol.Parent = plr
fol.Name = "Weapons"
dataweap:Get(default)
for i,v in pairs(dataweap:Get())do
local tag = Instance.new("BoolValue")
tag.Parent = fol
tag.Name = v
end
dataweap:OnUpdate(function(new)
for i,v in pairs(fol:GetChildren())do -- remving old values in the folder
v:Destroy()
end
for i,v in pairs(dataweap:Get())do -- Adding new bool values
if game:GetService("ReplicatedStorage").Weapons:FindFirstChild(v)then
local tag = Instance.new("BoolValue")
tag.Parent = fol
tag.Name = v
end
end
dataweap:Set()
end)
end)
Giver script:
local par = script.Parent
local cool = false
par.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")and cool == false then
cool = true
if game.Players:GetPlayerFromCharacter(hit.Parent)then
local name = game.Players:GetPlayerFromCharacter(hit.Parent)
local Datastore2 = require(1936396537)
local dataweap = Datastore2("Weapons",name)
local weap = game.ReplicatedStorage.Weapons:GetChildren()
local ran = weap[math.random(1,#weap)]
print(ran)
table.insert(dataweap, ran.Name)
for i,v in pairs(dataweap:Get())do -- Just to check what is in the data
print(v)
end
print(dataweap)
end
wait(7)
cool = false
end
end)
The giver gives a player random weapons when they touch it. So this actually print out:
-- Magic Staff
-- Wooden Sword
-- Wooden Bow
-- Wooden Spear
So I think that there is some problem with the table.insert thing in the giver script or is there a different way to put string values into a datastore2 table? Help please, Thank you

2 comments
It's my first time seeing a DataStore being required...What does it do?
It's some DataStore ModuleScript that simplifies data storage.