Problem scripting Im getting the error code," attempt to index nil with 'Parent' "

Hello i am a kid that is currently learning scripting, I have gotten the error code " [attempt to index nil with ‘Parent’ " in my script, and simply cannot figure out how to fix it. what is the problem, and please explain why this happened. Thank you for your help
line 12 is where the error is.
full script:

–Is there a player standing on me?

–varaibles
local campfire = script.Parent
local campgaurd = false

–on touch
local function onTouch(partTouched)
local character = partTouched.Parent
local humanoid = character:FindFirstChildWhichIsA(“Humanoid”)
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
local playerstats = player:FindFirstChild(“leaderstats”)
local playerlogcount = playerstats:FindFirstChild(“log count”)

if humanoid and campgaurd == false then
	
	if playerlogcount.Value == 1 then
    playerlogcount.Value = 0
    print ("you have given me a log")
		
	end
	
	
	campgaurd = true
end

end
campfire.Touched:Connect(onTouch)

1 Like

Send the script correctly please.

Thank you

You’re not allowed to be here if you are under the age of 13…

Attempt to index nil with ‘Parent’
Means that you are trying to do something to an object that doesn’t exist or is just nil

1 Like

He never stated his age. Just because he said he was a kid doesn’t necessarily mean he is under 13.

Thank you, after looking through my script for a little while longer, and comparing it to my teacher’s script, i have found out that the script indeed does work as intended. even though the error code message still appears. so I now belive that this is just a bug in roblox studio.

Thanks.