So I have this data store that isn’t working, it used to work before and I did not change anything with the script.
local DataStore = "GameTest"
game:GetService("Players").PlayerAdded:Connect(function(newPlayer)
local vs = script:WaitForChild("Data"):clone()
vs.Parent = game:GetService("ReplicatedStorage").PlayersData
vs.Name = newPlayer.UserId
local Data3 = vs:GetChildren()
local S2 = {}
for i=1,#Data3 do
local n = Data3[i].Name
S2[n] = Data3[i].Value
end
if newPlayer.Name ~= "Player" then
local DataStore4 = game:GetService("DataStoreService"):GetDataStore(newPlayer.userId,DataStore)
if DataStore4:GetAsync("Data",DataStore) == nil then
DataStore4:SetAsync("Data", S2,DataStore)
end
S2 = DataStore4:GetAsync("Data",DataStore)
end
local vv = vs:GetChildren()
for i=1,#vv do
local n = vv[i].Name
if S2[n] ~= nil then
vv[i].Value = S2[n]
end
end
end)
game:GetService("Players").PlayerRemoving:connect(function(p)
local DataStore5 = game:GetService("DataStoreService"):GetDataStore(p.userId,DataStore)
local Data2 = game:GetService("ReplicatedStorage").PlayersData[p.userId]:GetChildren()
local s2 = {}
for i=1,#Data2 do
local n = Data2[i].Name
s2[n] = Data2[i].Value
end
DataStore5:SetAsync("Data",s2,DataStore)
end)
I got errors at line 16 and 38 saying
21:58:04.232 Unable to cast to Array - Server - DataStore:38
21:58:04.232 Stack Begin - Studio
21:58:04.232 Script 'ServerScriptService.DataStore', Line 38 - Studio - DataStore:38
21:58:04.232 Stack End - Studio
There is a folder in ReplicatedStorage called “PlayersData” incase you want to know.