Closed uatemycookie22 closed 4 years ago
Requiring by ID is deprecated and the free model is a very old version. Let me know if this persists on the latest version.
Also, please try to format your code better.
Can confirm on master. Code:
local DataStore2 = require(game:GetService('ReplicatedStorage').DataStore2)
local MainKey = "PlayerData"
DataStore2.Combine(MainKey, "BuildInfo")
local function BuildInfoUpdate(player, NewData)
print("Changing BuildInfo:")
for i, v in pairs(NewData) do
print(i, v)
end
end
game.Players.PlayerAdded:Connect(function(player)
print("Player joining!")
local BuildStore = DataStore2("BuildInfo", player)
local BuildInfo = BuildStore:GetTable({1,3,2})
BuildStore:OnUpdate(BuildInfoUpdate)
print('buildinfo: '.. tostring(BuildInfo))
for i,v in pairs(BuildInfo) do
print(i, v)
end
BuildStore:Set({3,2,1})
end)
Output:
Player joining!
buildinfo: table: 0x6617006ea599b183
1 3
2 2
3 1
Changing BuildInfo:
combinedName BuildInfo
onUpdateCallbacks table: 0xe2979dcd7ed58543
combinedStore table: 0x07329bf2b9d8de43
combinedInitialGot true
This is because you're both using OnUpdate wrong. The first parameter of OnUpdate is the data, not the player. This isn't a bug.
Setting a table to a datastore is fine and works well. However, when you call :OnUpdate and pass the table to a function, the table passed is cyclic.
This code replicates the issue:
DataStore2 = require(1936396537) MainKey = "PlayerData1"
DataStore2.Combine(MainKey, "BuildInfo")
game.Players.PlayerAdded:Connect(function(player) print("Player joining!") local function BuildInfoUpdate(player, NewData) print("Changing BuildInfo:") print(NewData) end
end)