Attempt to index nil with "FindFirstChild" problem

So i have a problem with a error saying “Attempt to index nil with “FindFirstChild”.” even though i followed a tutorial and even tried copying the script in description, but the problem is still there.

I don’t know why it doesn’t work, but i assume that the player variable in the function is not actually player, but instead just a regular variable called “player”.

Here is the problematic part of the module script :

function PlayerManager.GetCash(player)
local leaderstats = player:FindFirstChild(“leaderstats”)
if leaderstats then
local Cash = leaderstats:FindFirstChild(“Cash”)
if Cash then
return Cash.Value
end
end
return 0
end

And here is the link to the tutorial i followed : https://www.youtube.com/watch?v=_63TM15fF1g&list=PLXSd5YZgxaXRMUSWybIRkELeIQLXJNZM7&index=4&ab_channel=BRicey

I will appreciate any help!

how are you calling the function

Yes, I was about to say that. Are you passing any parameters when calling (using) the function?

Yes i do
I have : Player, Cash - cost.

Can you show the line of the script where you call the function?

Perhaps you’re sending an argument that actually contains nil for the player parameter.

Would it be fine to send us another piece of your code responsible for calling PlayerManager.GetCash()?

You actually helped me a lot, because of your reply i realised that i got the parameter “Player” instead of “player” and now it works! Thank you!