Is there way to use variables in . idk stuff

so what i want to do is probably later make a tycoon or upgrade tree but i dont want to mess with the datastores im too lazy to check if the every upgrade is bought
is there a way to make something like

local data = game:GetService("DataStoreService")
local dat = data:GetDataStore("bla bla")
local v = "Upgrade"
local newDat = {}
newDat.v = true -- i want it to compile it as newDat.Upgrade is there a way to do that
dat:SetAsync("bla bla", newDat)
newdat[v] = true
4 Likes

you can do

local newDat = {
    Upgrade = true
}

-- or

local newDat = {}
newDat.Upgrade = true

or like @1kaelen1 suggested, use the variable as an index.

thanks, i will check it and if it works it would be very good to save stuff in game

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.