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)