Ok so i have been working on this script, trying to make it save the children in the Weaps model and then load it into the model when the player enters, everything looks like it would work but when i test it the output says "Cannot store Array in DataStore" or somthing? Can somone tell me what that means and how to fix it?
local datastore = game:GetService("DataStoreService"):GetDataStore("RobloxBackPack")
-------------------------------------------------------------------------
local wm = Instance.new("Model")
wm.Name = "Weaps"
function give(weap, player)
for _, w in ipairs(game.StarterPack:GetChildren()) do
if w.Name == weap.Name then return end
end
weap:clone().Parent = player.Weaps
end
game.Players.ChildAdded:connect(function(p)
wm:clone().Parent = p
wait()
p.Character.ChildAdded:connect(function(wep)
if wep.className == "Tool" then
give(wep, p)
end
end)
p.Changed:connect(function(pr)
if pr == "Character" then
for _, w in ipairs(p.Weaps:GetChildren()) do
w:clone().Parent = p.Backpack
end
p.Character.ChildAdded:connect(function(wep)
if wep.className == "Tool" then
give(wep, p)
end
end)
end
end)
p.Backpack.ChildAdded:connect(function(h)
if h.className == "HopperBin" then
give(h, p)
end
end)
end)
game.Players.PlayerAdded:connect(function(player) --Datastore stuff
local key = "user-" .. player.userId
local storeditems = datastore:GetAsync(key)
if storeditems then
local Special = storeditems[1]
Special.Parent = player.Weaps
else
local get = player.Weaps:GetChildren()
for i, v in pairs(get)do
local Potato = v:clone()
local items = {Potato}
datastore:SetAsync(key, items)
end
end
end)
--Says it cannot save a data array?
game.Players.PlayerRemoving:connect(function(player) -- more datastore stuff
local get = player.Weaps:GetChildren()
for i, v in pairs(get)do
local Potato = v:clone()
local items = {Potato}
local key = "user-" .. player.userId
datastore:SetAsync(key, items)
end
end)

1 comment
I am trying to GetChildren() out of model and then save it to datastore then load it back