New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

How i can insert a "Diamonds" in Leaderstats?

Asked by 5 months ago

(Sorry for bad english)

Hi guys! Another simple request but i'm very bad with Lua... I need to insert another currency called "Diamonds", but.. if i try to insert the currency, not appear in game... This is the script without the diamonds currency ->

-- local diamondsName = "Diamonds"
local serverStorage = game:GetService("ServerStorage")
local currencyName = "Money"
local DataStore = game:GetService("DataStoreService"):GetDataStore("ProvaDataStore")


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

    local currency ="IntValue")
    currency.Name = currencyName
    currency.Parent = folder

    local ID = currencyName.."-"..player.UserId
    local savedData = nil   

        savedData = DataStore:GetAsync(ID)

    if savedData ~= nil then
        currency.Value = savedData
        print("Data loaded")
        currency.Value = 10

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

    local power ="NumberValue")
    power.Name = "Power"
    power.Parent = leaderstats

    local rebirths ="IntValue")
    rebirths.Name = "Rebirths"
    rebirths.Parent = leaderstats

    local dataFolder ="Folder")
    dataFolder.Name = player.Name
    dataFolder.Parent = serverStorage.RemoteData

    local debounce ="BoolValue")
    debounce.Name = "Debounce"
    debounce.Parent = dataFolder



2 answers

Log in to vote
Answered by 5 months ago

Jeah the script is nearly done. Only need to make a new Instance like this under Line 33

local diamonds ="NumberValue")
diamonds.Name = "Diamonds"
diamonds.Parent = leaderstats
diamonds.Value = 0
Thanks, but now if i test i have only Money value!! GuerraReturns 71 — 5mo
Jeah I probably know why. You created 2 leaderstats folder and thats probably causing a problem. Delete the second one. And put my code in line 15 and change the diamonds.Parent to diamonds.Parent = folder Paintertable 171 — 5mo
Works!!! I have change power.Parent = folder and rebirths.Parent = folder after your answer, and now works perfectly! Thanks GuerraReturns 71 — 5mo
No problem :)) Thanks for accepting! Paintertable 171 — 5mo
Log in to vote
Answered by 5 months ago

You can simply Create folder inside player called LeaderStats and inside that folder you can create as much currency values as you want, by creating intValues.

Answer this question