pickaxehitbox.Touched:Connect(function(hit)
if ismining == false then
if hit.Name == "Hitbox" or hit.Parent == "Rocks" then
print("mining")
ismining = true
local health = hit:WaitForChild("Health")
if health:IsA("NumberValue") then
health.Value -= 1
end
if ismining == true then
wait(1)
ismining = false
end
end
end
end)
I tried referencing it but it doesn’t work
the value is inside the rock but it returns an error saying
You dont need to yield that, no need to use WaitForChild() here. Try this:
pickaxehitbox.Touched:Connect(function(hit)
if ismining == false then
if hit.Name == "Hitbox" or hit.Parent == "Rocks" then
print("mining")
ismining = true
local health = hit.Health
print(health) -- check if that prints
if health:IsA("NumberValue") then
health.Value -= 1
end
if ismining == true then
task.wait(1)
ismining = false
end
end
end
end)
I havent seen your whole code, but doing that works for you?