Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How i can insert a "Diamonds" in Leaderstats?

(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")

game.Players.PlayerAdded:Connect(function(player)
	
	local folder = Instance.new("Folder")
	folder.Name = "leaderstats"
	folder.Parent = player	
	
	local currency = Instance.new("IntValue")
	currency.Name = currencyName
	currency.Parent = folder
	
	local ID = currencyName.."-"..player.UserId
	local savedData = nil	
	
	pcall(function()
		savedData = DataStore:GetAsync(ID)
	end)
	
	if savedData ~= nil then
		currency.Value = savedData
		print("Data loaded")
	else
		currency.Value = 10
	end
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local power = Instance.new("NumberValue")
	power.Name = "Power"
	power.Parent = leaderstats
	
	local rebirths = Instance.new("IntValue")
	rebirths.Name = "Rebirths"
	rebirths.Parent = leaderstats
	
	local dataFolder = Instance.new("Folder")
	dataFolder.Name = player.Name
	dataFolder.Parent = serverStorage.RemoteData
	
	local debounce = Instance.new("BoolValue")
	debounce.Name = "Debounce"
	debounce.Parent = dataFolder
	
end)

Thanks!

2 answers

✓ Accepted answer

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

local diamonds = Instance.new("NumberValue")
diamonds.Name = "Diamonds"
diamonds.Parent = leaderstats
diamonds.Value = 0

4 comments

0

Thanks, but now if i test i have only Money value!!

0

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

1

Works!!! I have change power.Parent = folder and rebirths.Parent = folder after your answer, and now works perfectly! Thanks

0

No problem :)) Thanks for accepting!

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.