Hello. So I have a mainscript, and within that a function that looks like this:
function awardcredit(player, credits)
if player and credits then
local leaderstats = player:FindFirstChild("leaderstats") -- line 32 btw
if leaderstats then
local value = leaderstats:FindFirstChild("BlitzCreditz")
if value then
value.Value = value.Value + credits
end
end
end
end
This is supposed to add some credits (A value on the leaderboard. More on that in a moment...) This is where I call this function in the script
awardcredit(activecontestants, 4)
I also have my leaderboard set up like this...
function playeradded(player)
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Wins"
points.Parent = leaderstats
points.Value = 0
local BC = Instance.new("IntValue")
BC.Name = "BlitzCreditz"
BC.Parent = leaderstats
BC.Value = 0
end
game.Players.PlayerAdded:connect(playeradded)
for _, player in pairs(game.Players:GetPlayers()) do
playeradded(player)
end
The output says this when I get to the
awardcredit(activecontestants, 4)
in the script...
workspace.MainScript:32: attempt to call method 'FindFirstChild (a nil value)
Any idea why?

1 comment
Can you show you declaration of 'activecontestants'?