local FinishLine = script.Parent
FinishLine.Touched:Connect(function(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
local player = game.Players:GetPlayerFromCharacter(partParent)
local stat = player:WaitForChild('leaderstats'):WaitForChild('Laps')
local bool = game.StarterPlayer:WaitForChild('hasHitCheckpoint')
if (humanoid and bool.Value == true) then
stat.Value = stat.Value + 1
bool.Value = false
end
end)
The issue is that the code above returns an “Attempt to index local 'player '(a nil value)” error whenever a player touches FinishLine, as seen in the screenshot below.
Is it possible that I could get rid of these errors? If so, how?
(keep in mind that the code works)

