Problem with currency

local player = game.Players.LocalPlayer
local sss = script.Parent
local pd = sss.PlayerData
local data = pd.Data
local manager = require(pd.Manager)
local rs = game:GetService("ReplicatedStorage")
local oreevent = rs.GetOre
local oremultiplier = math.random(1.1, 2)
local pickstrength = require(pd.Pickaxe)
local wpick = pickstrength.woodpick
local sc = rs.ServerConnector

local function addore(player: Player)
	manager.AdjustOres(player, 1)
	print("succes")
end

sc.OnServerEvent:Connect(addore)
local Manager = {}

Manager.Profiles = {} --profile, storing data

function Manager.AdjustMoney(player: Player, amount: number)
	local profile = Manager.Profiles[player]
	if not profile then return end
	profile.Data.Coins += amount
	player.leaderstats.Coins.Value = profile.Data.Coins
end

function Manager.AdjustOres(player: Player, amount: number)
	local profile = Manager.Profiles[player]
	if not profile then return end
	profile.Data.Ore += amount
	player.leaderstats.Ore.Value = profile.Data.Ore
end

return Manager

There’s an error saying
image
i don’t understand why and what’s the problem here? Can anyone help

why are you doing the amount: number thing? really goofy. I’d just do function Manager.AdjustOres(Player,Amount). I don’t know what the : does but if I were to guess it thinks player is player you sent in the script, and Player is 1, whereas amount and number are just nil.

or maybe Coins is nil; did you forget to set that somewhere?

Can you print out the two values you are adding, so we can see where the problem is?

How could i do that?
I tried these:
print(profile.Data.Ore)
print(player.leaderstats.Ore.Value)
but it doesn’t show the value in the output

im pretty sure i’ve set that in this script ( correct me if im wrong )

	local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")

local Template = require(ServerScriptService.PlayerData.Template)
local Manager = require(ServerScriptService.PlayerData.Manager)
local ProfileService = require(ServerScriptService.Libs.ProfileService)

local ProfileStore = ProfileService.GetProfileStore("devtest", Template) --key/password utk data

local KICK_MESSAGE = "Data Issue, try again shortly, If issue persists, contact us!"

local function CreateLeaderstats(player)
	local profile = Manager.Profiles[player]
	if not profile then end

	local leaderstats = Instance.new("Folder", player)
	leaderstats.Name = "leaderstats"

	local Coins = Instance.new("NumberValue", leaderstats)
	Coins.Name = "Coins"
	Coins.Value = profile.Data.Coins
	
	local Ores = Instance.new("NumberValue", leaderstats)
	Ores.Name = "Ore"
	Ores.Value = profile.Data.Ores
end

local function LoadProfile(player: Player)
	local profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId)
	if not profile then
		player:Kick(KICK_MESSAGE)
		return
	end

	profile:AddUserId(player.UserId)
	profile:Reconcile()
	profile:ListenToRelease(function()
		player:Kick(KICK_MESSAGE)
		Manager.Profiles[player] = nil
	end)

	if player:IsDescendantOf(Players) == true then
		Manager.Profiles[player] = profile
		CreateLeaderstats(player)
	else
		profile:Release()
	end
end

for _, player in Players:GetPlayers() do
	task.spawn(LoadProfile, player)
end

Players.PlayerAdded:Connect(LoadProfile)
Players.PlayerRemoving:Connect(function(player)
	local profile = Manager.Profiles[player]
	if profile then
		profile:Release()
	end
end)

and the leaderstats shows up
image

i don’t really understand it pretty well because it’s from a tutorial ( https://www.youtube.com/watch?v=UAXGwGsxpR8&list=PLl1Tso3TyF55UEnXsYkmsamFqKUBdgo1S ) and it works on my other game
Here’s the script on my other game :

local Manager = {}

Manager.Profiles = {} --profile, storing data

function Manager.AdjustMoney(player: Player, amount: number)
	local profile = Manager.Profiles[player]
	if not profile then return end
	profile.Data.Money += amount
	player.leaderstats.Money.Value = profile.Data.Money
end

return Manager

it has the same function to add the money value too :
image

The issue is, you are using =+,
Try to use CURRENT CASH AMOUNT + ADDING CASH =.


same error

IT returns an nil. Could you please check if every value exists?