Does anyone have any recommendations on how to make a good currency system

Hey! I am currently working on a game and I need help making a coding system for currency, I want it to be able to go onto user interface, and be able to keep and store data,

(Sorry if it is not inside the right topic, couldn’t really find one that fit this)

1 Like

Are you trying to make a leaderboard system or a Screen Gui that says the amount of currency the player has?

A screen gui, but I want it to be flexible, in a way where NPCs can give you currency, etc

Firstly, you will need to use datastores to save the currency.Tutorial on datastores
If you want this data to be on a screen gui then you will need to transfer the data with a remote event. (allows server and client to communicate through scripts)
Now that you have the data, you can set the text to the currency value.

script in serverscriptservice

local dss = game:GetService("DataStoreService")
local CurrencyVal = dss:GetDataStore("CurrencyValue")
local rs = game:GetService("ReplicatedStorage")


	local leaderstats ="Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local currency ="IntValue") --this is the currency
	currency.Name = "currency"
	currency.Parent = leaderstats
	local plrKey = "id_" .. player.UserId
	local saved = CurrencyVal:GetAsync(plrKey)
	local save = player.leaderstats.currency

	if saved then
		save.Value = saved[1]

	CurrencyVal:SetAsync("id_"..player.UserId,{player.leaderstats.currency.Value}) --use this whenever you give the player an amount of currency

local script in screen gui

local replicatedStorage = game:GetService("ReplicatedStorage")
local CurrencyGui = script.Parent.Amount

CurrencyGui.Text = "Amount of currency: "

this is what your screenGui should look like in starterGui

you also need a remote event in replicatedStorage called Currency

I am not experienced with NPC’s but I’m sure there’s a tutorial out there
Let me know if anything isn’t functioning correctly