The BoolValue
method would be relatively inefficient. Instead, I’d recommend doing this:
Create a folder inside of the player called OwnedTitles
, and do the following:
When the player buys a title, create a StringValue. Then, set its Value
property to the title’s Text, e.g “Adventurer”, or “Epic”. Then put this value inside of the OwnedTitles
folder. I’d create a function to simplify this process, as you’ll need to create a TitleName
value again later on in this post. It would look like this:
local function createTitleName(folder, nameOfTitle)
local titleName = Instance.new("StringValue")
titleName.Value = nameOfTitle
titleName.Parent = folder
end
Now, whenever the player leaves, use :GetChildren()
on their folder, and add each of the StringValue’s Value
properties to a table, like this:
local ownedTitles = {}
for _, obj in ipairs(OwnedTitlesFolder:GetChildren()) do
table.insert(ownedTitles, obj.Value)
end
Now save this table using DataStoreService
.
When the player joins, load this table using DataStoreService
. Loop through the table like this:
for _, titleName in ipairs(loadedOwnedTitlesTable) do
createTitleName(ownedTitlesFolder, titleName)
end
Keep in mind that most of this code has undefined variables, so you’ll need to define them yourself.