Making a Title Inventory System

image

The image above is my current inventory system. It basically uses a saved bool value and if it’s true, it gives them the named title. It’s a pretty simple system which I want to upgrade.

I want to know how I would load the player’s saved titles without using a saved bool value to check.

(Also is there a way to set the title’s color without saving it?)

1 Like

I dont understand exactly what your system does. Whats inside Administrator or Billionaire?
And how it works? a player joins, check its userId and find in which category belongs to give them a title?

For every title you would have a numerical id that is used to reference a title, for example:
1 = Administrator
2 = Billionaire
3 = Game Creator
So on and so forth, you can save these numbers into an array and save that single array into a datastore. Then when you want to load the titles a player has you would just retrieve that array and go through it and see what titles the player has and give it to them.

1 Like

So I just insert what titles the player has into a table?

image

It just stores the title color.

Yes, that is my current system.

You can insert just a number id that represents a title. And for saving a title color you can just serialize and deserialize a color3 value.

If you already have a datastore saving what title the player is, you could only read that value and find it in a server table to get the properties of that title. And you could add more properties to each title. Something like this maybe:

local Titles = {}
Titles["Admin"] = {Color = Color3.fromRGB(255, 162, 0)}
Titles["Moderator"] = {Color = Color3.fromRGB(0, 255, 30)}

local DSS = game:GetService("DataStoreService")
local Titles = DSS:GetDataStore("Titles")

game.Players.PlayerAdded:Connect(function(player)
	local succ, data = pcall(function()
		return Titles:GetAsync(player.UserId)
	end)
	if succ then
		if data then
			warn("The color of your title is:", Titles[data]["Color"])
		else
			warn("player has no data")
		end	
	else
		warn("datastore reading failed")
	end
end)
1 Like

Alright, I’ll try this and let you know how it goes.

1 Like

I spent longer than expected on this, but I finally got it working. The titles save and load correctly. I would’ve never thought of using tables to store the data of titles their properties, so thank you!

1 Like

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