(REUPLOAD) so I'm doing a team create with another person. I did a script for a NPC to go over to a tree, then chop it down. I did the chopping down in the tree script, but it did not work after about 20 times. can somebody help? code:
local leaves = script.Parent.leaves
local trunk = script.Parent.trunk
if game.Workspace.treesetup.Value == 0 then
workspace.treechopgui.Value = 0
workspace.makeanothertree.Value = 0
workspace.treechoped.Value = 0
trunk.Transparency = 1
leaves.Transparency = 1
local treescreated = 0
print("tree setup started")
game.Workspace.treesetup.Value = 1
while true do
wait(0.7)
if treescreated == 0 or treescreated == 1 or treescreated == 2 or workspace.makeanothertree.Value == 1 then
workspace.makeanothertree.Value = 0
local clone = script.Parent:Clone()
clone.Parent = script.Parent.Parent
clone.Name = "tree"
print("tree made")
treescreated = treescreated + 1
workspace.treechopgui.Value = 0
workspace.treechoped.Value = 0
end
end
end
if game.Workspace.treesetup.Value == 1 then
leaves.Transparency = 0
trunk.Transparency = 0
trunk.Position = Vector3.new(-131, 5.5, -125)
trunk.Position = trunk.Position + Vector3.new(math.random(-100, 0), 0, math.random(-100, 0))
leaves.Position = trunk.Position + Vector3.new(0,5,0)
function onTouched(hit)
print("touched")
print(hit.Parent.Name)
if hit.Parent.Name == workspace.playername.Value or hit.Parent.Parent.name == workspace.playername.Value then
print("player")
workspace.treechopgui.Value = 1
if workspace.treechoped.Value == 1 then
workspace.treechoped.Value = 0
workspace.treechopgui.Value = 0
workspace.makeanothertree.Value = 1
if workspace.turtorailno.Value == 5 then
workspace.turtorailno.Value = 6
workspace.invintory.trees.Value = workspace.invintory.trees.Value + 1
script.Parent:Destroy()
else do
local name = hit.Parent.Name
print("npc")
local noob = hit.Parent
script.Parent:Destroy()
end
end
end
end
end
trunk.Touched:Connect(onTouched)
end

1 comment
Please tell me you leave indentation in when you code and that this is just a copy paste issue.. and could you also explain where you are getting your error and what that error is?