test2(line 27) gets printed out, but test(line 29) doesn't. Here is the code:
local dmg = 0
local hasHit = false
local function WoodHit(hit)
local hum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
print(hum)
print(hum.Health)
print(hit.Parent.Name)
print(script.Parent.Name)
if hum ~= nil and hum.Health > 0 and hit.Parent.Name ~= script.Parent.Name and hasHit == false then
hasHit = true
local hitParticle = game.ReplicatedStorage.WoodStuff.HitParticle:Clone()
hitParticle.CFrame = hit.CFrame.LookVector * 2
hitParticle.Parent = hit
print(hitParticle.Parent:GetFullName())
wait(.5)
hitParticle:Destroy()
end
end
script.Parent.ChildAdded:Connect(function(child)
if child:IsA("Model") and child.Name == "WoodRelease" then
print(child:GetFullName())
local wood = script.Parent:WaitForChild("WoodRelease"):GetChildren()
print("test2")
for i = 1, #wood do
print("test")
wood[i].Touched:Connect(WoodHit)
end
end
end)
script.Parent.ChildRemoved:Connect(function(child)
if child:IsA("Model") and child.Name == "WoodRelease"then
hasHit = false
end
end)
