Using WaitForChild on the leaderstats and saving the ValueBase instance rather than their values should work.
I am not sure I understand why you parameter the player when you have the self argument (which is your new instance object).
Would suggest this instead: (in addition, I personally prefer stating the type of the parameter, then not needing to convert it, but that is up to you)
function StatFunctions:AddCash(amount : number)
self.Cash.Value += amount
end
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local StatFunctions = require(ServerStorage.StatFunctions)
Players.PlayerAdded:Connect(function(player)
local playerStat = StatFunctions.new(player)
playerStat:AddCash(10)
end)
it doesn’t find the leaderstats because it fires before the folder (what I’m assuming) spawns in so you should make a slight delay like around 2 seconds
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local StatFunctions = require(ServerStorage.StatFunctions)
Players.PlayerAdded:Connect(function(player)
local PlayerStats = StatFunctions.new(player)
StatFunctions:AddCash(10)
end)
Pretty sure it’s adding the cash, I just don’t think its displaying it.
Doesnt look like anywhere in the script you are updating leaderstats.Cash, update it in the :AddCash function and see how that works. (set leaderstats.Cash.Value to self.Cash after you increment the self.Cash)