I have been scripting on Roblox for about a year now but I have never had to use these kind of values and commands so I am still a newbie. I have looked at other peoples questions on this same error and also have watched videos on it but it hasn't helped me a single bit. I have tried everything I could think of but I just need help. I am trying to make a tree that gives you wood when you cut it down. Here's the script...
local z = script.Parent
local x = z.Log
local y = z.Leaves
local hits = 0
local maxhits = 8
x.Touched:connect(function(hit)
if hit.Name == "PlainAxe" then
hits = hits + 1
if hits >= maxhits then
hits = 0
-- This is what I need Help With...
local char = hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(char)
player.Stats.Wood.Value = player.Stats.Wood.Value + 10
-- The rest of this works just fine when I remove the segment above.
script.Parent.Leaves.Position = Vector3.new(-444.95, -34.9, -282.2)
script.Parent.Log.Position = Vector3.new(-444.9, -24.25, -282.55)
wait(10)
script.Parent.Leaves.Position = Vector3.new(-444.95, 22.9, -282.2)
script.Parent.Log.Position = Vector3.new(-444.9, 9.75, -282.55)
print("Complete")
end
end
end)

2 comments
were getting somewhere! I changed it up a bit and now i just need to make it wait untill the "wood" value has loaded
You don't pass the humanoid through
GetPlayerFromCharacteryou pass reference to the model of the attempted character.