If (NameValue).Value == true then it does not work

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)

add a .Value

if  hit.Parent:FindFirstChild('Acción').Value == true then
1 Like

Yea you didn’t put .Value in there as what @Kaid3n22 showed

1 Like

Thats gonna error if there is no “Acción” in the “hit”

Better to do :

local Found  = hit.Parent:FindFirstChild('Acción')
if Found and Found.Value then
1 Like

He already checked for something. i’m assuming if it has that in it, it will have Accion in it too.

1 Like
local b = hit.Parent:FindFirstChild('Acción')
if b and b.Value then
  -- something
end
1 Like

Well if he is sure about the existence of Accion he can do it , as a viewer I don’t know how his structure of Axe exists.

1 Like