Problem with referencing Health

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
image
the value is inside the rock but it returns an error saying
image

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?

wow thankyou it works now ( character requirement )

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.