Save/Load Menu Helper
Key Required VerifiedUniversal

Save/Load Menu Helper

Universal ScriptTrustsenseTrustsense 25.7K views 56 executesUpdated May 21, 2022
Unrated
00
Lua Script•65 lines (1401 chars)
local Test = { NewTable = { AutoFarm = true } }

local http = game:GetService("HttpService")

function Save(hub, name, settings)
    if not isfolder(hub) then
        makefolder(hub)
    end
    local path = hub .. "/" .. name .. ".json"

    local objects = {}

    for i, v in next, settings do
        if type(v) == "table" then
            objects[i] = Save(i, v)
        else
            objects[i] = v
        end
    end

    local success, result = pcall(http.JSONEncode, http, objects)
    if not success then
        return result
    end

    writefile(path, result)
    return true
end

function Load(hub, name, settings)
    local path = hub .. "/" .. name .. ".json"

    local success, result = pcall(readfile, path)
    if not success then
        return result
    end

    local objects = {}
    local success, decoded = pcall(http.JSONDecode, http, result)
    if not success then
        return decoded
    end

    for i, v in next, decoded do
        if type(v) == "table" then
            objects[i] = Load(i, v)
        else
            objects[i] = v
        end
    end

    for i, v in next, objects do
        settings[i] = v
    end

    return true
end

Save("ee", "Test", Test.NewTable) -- Page Case
Load("ee", "Test", Test.NewTable) -- Page Case

for _, v in next, Test do
    Save("ee", "Test", v) -- Entire Menu Case 
    Load("ee", "Test", v) -- Entire Menu Case
end

Features & Information

Mhmm, inspired by wally, you can uh, use it if u want

Community Comments (2)

zacharydafrowzacharydafrowMay 22, 2022(edited)

Pls explain this script. Can i save my progress from a random tycoon game?

FactsFactsAug 30, 2022(edited)

@zacharydafrow it saves ui data, like configs for a game basically when u run the script again, whatever u had toggled will still be on

More Scripts for Universal Scripts