How do you save a Table with stored Usernames in a Server?

I want to make a game, with a Login System for my community, it’s bascially a “Site on Roblox” for my Community, where people can login with their custom created accounts, and check latest news and post comments ; etc.

Im facing a problem, I made a **table which contains usernames and always inserts one when a user is in platform. (So when user signs up) **So my question is how can I save this table to a server which will then send it back when a player joins. Example; New account; Gamer539099 > Store in table “Usernames” > When “BindToClose” save the Username in the table + id.
When a player joins back, load back the whole table.

I looked around on the Developer Hub, but I didn’t find anything revelant.
I tried with datastore ; bindtoclose but it always just throws keys, and when I join back it would “forget everything”

local Usernames = {
}
game:BindToClose(function(player)
    for _,v in pairs(game.Players:GetPlayers()) do
        local UId = v.UserId
        local Data = Usernames[UId]

        if game:GetService("RunService"):IsStudio() then
            return
        end
        if Data then
            local Success, Failure = pcall(function()
                DataUsers:SetAsync(player.UserId,Usernames)
            end)
            if Success then
                print(Success)
            else
                error(Failure)
            end
        end    
    end
    print(Usernames)
end)

Im still facing many problems with this, tough I tried other methods they didn’t work.
Help is very appreciated.

You will have to Call HttpService:JSONEncode() on the table while saving it and while loading, use HttpService:JSONDecode(). Hope this helps! :grinning_face_with_smiling_eyes:

1 Like

I’ll try, seems helpful, thanks!