Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Would I Re-Assemble This Script To Save And Change Values In Tables?

Asked by 4 years ago

So, I've created a table using HTTP Service and JSON:Encode and JSON:Decode.

I can't figure out how to save this table and change the values inside of it?

ServerScript inside ServerScriptService:

game.Players.PlayerAdded:Connect(function(player)
    local swordData = Instance.new("Folder",player)
    swordData.Name = "SwordData"

    local ns = Instance.new("BoolValue",swordData)
    ns.Name = "NS"


    local http = game:GetService("HttpService")

    local items =
    {
        Swords = 
        {
        ["Normal Sword"] = true,
        ["Cool Sword"] = false
        }
    }   

    wait()

    local savedTable = http:JSONEncode(items)

    print(savedTable)

    local loadedTable = http:JSONDecode(savedTable)

    print(loadedTable.Swords["Normal Sword"])

    player.SwordData.NS.Value = loadedTable.Swords["Normal Sword"]
end)

Any help would be appreciated!

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

well you need to use the Datastore service, datastore service saves strings, and numbers to the Roblox Servers, you can retrieve the data and do whatever you want to with it; since i don't have much time as of right now, Here are videos and articles that explain Datastore service

ALvinBlox

Roblox Docs;

Roblox Doc Article

Good luck!

0
Thanks! killerbrenden 1537 — 4y
Ad

Answer this question