coroutine.wrap(function()
for a,b in pairs(Area1Trees:GetChildren()) do
local distarea1tree = b
if mainrangefromtrees > (distarea1tree.Position - tool.Handle.Position).magnitude then
if mouse.Target == b then
if firstattack == false then
if CrackingTheTreePart.Size.X < 1.6 or CrackingTheTreePart.Size.X > 0 then
CrackingTheTreePart.Size = CrackingTheTreePart.Size + Vector3.new(TreeAttackSizePlus,0,0)
end
if CrackingTheTreePart.Size.X > 1.6 then
CrackingTheTreePart.Parent = game.ReplicatedStorage.CrackingPart
CrackingTheTreePart.Size = Vector3.new(.1, .2, 1.4)
game.ReplicatedStorage.DamageToTree:FireServer(oldtree,game.Players.LocalPlayer,oldtree.Parent.TreeSettings.Wood)
firstattack = true
wait(1)
end
if secondfirsttree == true then
if CrackingTheTreePart.Size.X > 1.6 then
CrackingTheTreePart.Parent = game.ReplicatedStorage.CrackingPart
CrackingTheTreePart.Size = Vector3.new(.1, .2, 1.4)
game.ReplicatedStorage.DamageToTree:FireServer(b,game.Players.LocalPlayer,b.Parent.TreeSettings.Wood)
firstattack = true
wait(.3)
end
end
end
if firstattack == true then
oldtree = b
CrackingTheTreePart.Parent = oldtree
CrackingTheTreePart.Anchored = true
CrackingTheTreePart.CFrame = oldtree.CFrame * CFrame.new(0,-mouse.Hit.Position.Y/mouse.Hit.Position.Y,0)
CrackingTheTreePart.Size = Vector3.new(.1, .2, 1.4)
firstattack = false
secondfirsttree = true
end
if secondfirsttree == true then
if mouse.Target ~= oldtree and mouse.Target == b then
CrackingTheTreePart.Parent = b
CrackingTheTreePart.Anchored = true
CrackingTheTreePart.CFrame = b.CFrame * CFrame.new(0,-mouse.Hit.Position.Y/mouse.Hit.Position.Y,0)
CrackingTheTreePart.Size = Vector3.new(.1, .2, 1.4)
firstattack = true
secondfirsttree = false
end
end
end
end
end
end)()
Error:
Players.Dquvo.Backpack.StarterAxe.LocalScript:20: Position is not a valid member of Folder “Workspace.Area1Trees.NormalTree.TreeSettings” - Client - LocalScript:20
21:47:26.688 Stack Begin - Studio
coroutine.wrap(function()
for a,b in pairs(Area1Trees:GetChildren()) do
local distarea1tree = b
if mainrangefromtrees > (distarea1tree.Position - tool.Handle.Position).magnitude then
if mouse.Target == b then
if firstattack == false then
if CrackingTheTreePart.Size.X < 1.6 or CrackingTheTreePart.Size.X > 0 then
CrackingTheTreePart.Size = CrackingTheTreePart.Size + Vector3.new(TreeAttackSizePlus,0,0)
end
if CrackingTheTreePart.Size.X > 1.6 then
CrackingTheTreePart.Parent = game.ReplicatedStorage.CrackingPart
CrackingTheTreePart.Size = Vector3.new(.1, .2, 1.4)
game.ReplicatedStorage.DamageToTree:FireServer(oldtree,game.Players.LocalPlayer,oldtree.Parent.TreeSettings.Wood)
firstattack = true
wait(1)
end
if secondfirsttree == true then
if CrackingTheTreePart.Size.X > 1.6 then
CrackingTheTreePart.Parent = game.ReplicatedStorage.CrackingPart
CrackingTheTreePart.Size = Vector3.new(.1, .2, 1.4)
game.ReplicatedStorage.DamageToTree:FireServer(b,game.Players.LocalPlayer,b.Parent.TreeSettings.Wood)
firstattack = true
wait(.3)
end
end
end
if firstattack == true then
oldtree = b
CrackingTheTreePart.Parent = oldtree
CrackingTheTreePart.Anchored = true
CrackingTheTreePart.CFrame = oldtree.CFrame * CFrame.new(0,-mouse.Hit.Position.Y/mouse.Hit.Position.Y,0)
CrackingTheTreePart.Size = Vector3.new(.1, .2, 1.4)
firstattack = false
secondfirsttree = true
end
if secondfirsttree == true then
if mouse.Target ~= oldtree and mouse.Target == b then
CrackingTheTreePart.Parent = b
CrackingTheTreePart.Anchored = true
CrackingTheTreePart.CFrame = b.CFrame * CFrame.new(0,-mouse.Hit.Position.Y/mouse.Hit.Position.Y,0)
CrackingTheTreePart.Size = Vector3.new(.1, .2, 1.4)
firstattack = true
secondfirsttree = false
end
end
end
end
end
end)()
this isn’t an answer to your problem I’m just helping other devs read the code with indentation
Area1Trees:GetChildren() returns an array of direct children of Area1Trees, as far as I can tell the folder NormalTree is the only direct child and a folder does not have a position property (which is probably the reason for the error).
Rather use Area1Trees:GetDescendants() which returns an array of all the descendants of Area1Trees and just filter out the objects you’re not interested in by checking if the object is a tree.
Or you could keep it as GetChildren() and check if the child’s name is NormalTree, if it is use GetChildren() on NormalTree to get the tree objects like so:
for a,b in pairs(Area1Trees:GetChildren()) do
if b.Name = "NormalTree" then
for i,v in pairs(b:GetChildren()) do
local distarea1tree = v