Hello! I am making an ingame currency following a tutorial (Roblox Scripting Tutorial: How to Script a Currency System - YouTube), and I’ve just finished typing it. However, I want to change the currency name from “coins” to “cash”. How would I do this?
My current script is as below:
local DataStoreService = game:GetService("DataStoreService")
local CurrencyStore = DataStoreService:GetDataStore("CurrencyStore")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
local UserId = Player.UserId
local Currency = CurrencyStore:GetAsync(UserId)
if Currency == nil then
Currency = 0
CurrencyStore:SetAsync(UserId, Currency)
end
local Leaderstats = Instance.new("Folder", Player)
Leaderstats.Name = "leaderstats"
local Coins = Instance.new("IntValue", Leaderstats)
Coins.Name = "Coins"
Coins.Value = Currency
Coins.Changed:Connect(function(NewValue)
CurrencyStore:SetAsync(UserId, NewValue)
end)
end)
Also this is a really simple DataStore script, It constantly would send messages to update and cause a lot of errors, If you have a table of everyone’s currency then you would be able to change the value of the table, then when they leave, save their Data to their Datastores
EDIT: Actually, I found out what caused this. While I was working on this, My computer ran out of battery, and saved an auto recovery file. I forgot that I’d have to republish the game and allow API services. It works now!
I was just suggesting a different way to not put so much stress on the Roblox Servers. For you, whenever anyone got any money then it would send a message to the great datastore servers in roblox, which takes like a second or so.