Hello I’m trying to have a datastore that saves the playerws info when they leave the game however it doesnt work. I tried printing stuff inside the removing event but nothing prints. this is my code:
local users = {}
game.Players.PlayerAdded:Connect(function(plr)
table.insert(users, {
["name"] = plr.Name,
["data"] = {}
}
)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local DSS = game:GetService("DataStoreService")
local RecordingsService = DSS:GetDataStore("Recordings")
for i,v in pairs(users) do
if v.name == plr.Name then
RecordingsService:SetAsync(plr.UserId,
{
["Data"] = users.data,
["Time"] = timestamp,
["Date"] = date
}
)
end
end
end)
When I try to call the datastore it’s just nil.