I am Datastoring tables, having a bit of an error using :SetAsync() function. When I use the SetAsync function, it doesn't really set the PlayerData is the Module script for that player. I need help, the output doesnt output any errors.
Module Script:
return {
PlayerData = { Coins = 0, Diamonds = 0, Experience = 0, Kills = 0, Level = 0, EXPneeded = 0, }
}
Script:
local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("PlayerDataV1");
local DataModule = require(game.ReplicatedStorage.PlayerData)
game.Players.PlayerAdded:Connect(function(plr)
for i, v in pairs(DataModule.PlayerData) do
DataStore:GetAsync(plr.UserId, v)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
for i, v in pairs(DataModule.PlayerData) do
DataStore:SetAsync(plr.UserId, v) -- v; the value of the instances when looped through the table.
end
end)

1 comment
Also, I test this out by changing the value of the Module script, as it is for NEW players.