✓ Accepted answer
This won't work for a few reasons.
First, table entries can use either , OR ; for separation, so you're constantly overwriting Color1 and Color2 here. You need to use nested tables.
As well, JSON-ifying function are part of the RbxUtility library, not the HTTPService.
You can use this article as reference in the future.
local Utils = assert(LoadLibrary("RbxUtility"))
local PlayerData = {
Money = 2500;
Plane1 = {false, Color1 = "",Color2 = ""};
Plane2 = {false, Color1 = "",Color2 = ""};
Plane3 = {false, Color1 = "",Color2 = ""};
Plane4 = {false, Color1 = "",Color2 = ""};
Plane5 = {false, Color1 = "",Color2 = ""};
}
local JSON = Utils.EncodeJSON(PlayerData)
local player = game.Players:GetPlayers()[math.random(game.Players.NumPlayers)]
if player then
player:WaitForDataReady()
player:SaveString("Stats", JSON)
end
That code uses Data Persistence instead of Data Stores, so I suggest against using it in that form. It also saves to a random player, so you'll have to modify it anyway.
1 comment
It would not work, because you spelled JSON wrong in line 11.