Hi, I'm trying to make a weapon datastore using datastore2. I way I think that I could do this is by saving the name of the weapons on a table and when the player joined, I would like to get all of the values in there and make a boolvalue with the weapons name from the table so I could get access to the weapon later in the game when a match start. Is it possible that I could just save the table and access it from other scripts? This is my script and the folder didn't appeared in the player when I tested and there was also no "Player Added" in the output:
local DataStore2 = require(1936396537)
game.Players.PlayerAdded:Connect(function(plr)
print("Player Added")
local dataweap = DataStore2("Weapons",plr)
local fol = Instance.new("Folder")
fol.Parent = plr
fol.Name = "Weapons"
local tbl = {}
print("Folder Added")
if dataweap:Get() ~= nil then
for i,v in pairs(dataweap:Get())do
table.insert(dataweap,v)
local tag = Instance.new("BoolValue")
tag.Parent = fol
tag.Name = v
end
else
table.insert(dataweap,"Wooden Bow")
local tag = Instance.new("BoolValue")
tag.Parent = fol
tag.Name = "Wooden Bow"
table.insert(dataweap,"Wooden Sword")
local tag = Instance.new("BoolValue")
tag.Parent = fol
tag.Name = "Wooden Sword"
table.insert(dataweap,"Wooden Spear")
local tag = Instance.new("BoolValue")
tag.Parent = fol
tag.Name = "Wooden Spear"
end
local function tblupdate(new)
local tabl = DataStore2:GetTable()
for i,v in pairs(tabl)do
print(v)
if game:GetService("ReplicatedStorage").Weapons:FindFirstChild(v) then --Check that the name of the weapon exist
if plr.Weapons:FindFirstChild(v)then -- So that I don't add 2 of the same weapon
else
local tag = Instance.new("BoolValue")
tag.Parent = fol
tag.Name = v
end
else
table.remove(dataweap,v)
end
end
end
dataweap:OnUpdate(tblupdate())
end)
Help please, Thank you.
