Hello, I will give you a brief summary of what I am trying to do. The following script is a tree felling system, in line 8 it should detect when the value of the ax is true in order to execute the following, but it does not and if I remove line eight, simply touch the tree with the ax begins to take life from the tree.
local health = 100
local bool = true
local ongoing = true
local respawn = math.random(8,20)
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('IsAAxe') and ongoing == true then
if hit.Parent:FindFirstChild('Acción') == true then
local status = hit.Parent:FindFirstChild('Type')
if health > 0 then
if status.Value == 'HachaDePiedra' then
health = health - 5
elseif status.Value == 'Uncommon' then
health = health - 10
elseif status.Value == 'Rare' then
health = health - 15
elseif status.Value == 'Epic' then
health = health - 20
end
end
print(health)
elseif health <= 0 and bool == true then
bool = false
for i, x in pairs(script.Parent.Parent:GetChildren()) do
x.Transparency = 1
x.CanCollide = false
end
local wood = game.ReplicatedStorage.Materiales.Cargarmateria:Clone()
wait(0.01)
wood.Parent = workspace.SistemaDeTalado
wood:MoveTo(script.Parent.Position)
ongoing = false
health = 100 -- [ Put the original health here ] --
wait(respawn)
for i, x in pairs(script.Parent.Parent:GetChildren()) do
x.Transparency = 0
x.CanCollide = true
end
bool = true
ongoing = true
end
end
end)