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

How do you index a string variable and change an index?

Asked by 2 years ago

I want to save a list to the Datastores, but I really don't know anyway how to, so I went with creating a folder with a string variable, and planned to use it like a list. My plan was to use a binary system as 0 or 1 to enable something, but don't know how to change a single part of it because string.gsub will find multiple 1s or 0s. Here's what my code looks like:

Server Script Creating String Value:

local Binary = Instance.new("StringValue",Achievements)
    Binary.Name = "Binary"
    Binary.Value = AD:GetAsync(Player.UserId) or "1000000000"
    Binary.Changed:Connect(function()
        AD:SetAsync(Player.UserId, Binary.Value)
    end)

Client Script Working With And Sending Back It To Save:

local Binary = Player.achievements.Binary.Value
local Value = Player.leaderstats.Value.Value

--Value is detection for whether to change
Value.Changed:Connect(function()
    if(Value>10) then
        --Where I want to change an index of string
    end
    ReloadGui(Binary)
end)

--Change Gui by reading Binary
function ReloadGui(list)
    if (string.sub(Unlocks, i, i) == "1")then
        NewFrame.Visible = true
    elseif (string.sub(Unlocks, i, i) == "0") then
        NewFrame.Visible = false
    end
end)

I know I'm probably over complicating it but I saw this as an easier way without any knowledge of Datastores and Dictionaries. ;-;

Answer this question