Problem with touch function

Here’s the function :

		pickaxehitbox.Touched:Connect(function(hit)
			if ismining == false then
				if hit.Name == "Hitbox" or hit.Parent == "Rocks" then
					print("mining")
					ismining = true
					if ismining == true then
						wait(1)
						ismining = false
					end
				end
			end
		end)
		task.wait(1)
		canmine.Value = true
	end
end)

It seems to have an error but i dont know what’s the problem here.
image
Pickaxe hitbox :
image
Rock hitbox :
image

1 Like

The ‘pickaxehitbox’ variable is referencing a Motor6D. You will have to change the declaration to the hitbox.

i don’t understand, earlier i tested it and it worked perfectly fine. And what do you mean by “changing the declaration to the hitbox”

how would i change the “declaration” to the hitbox

The hitbox is supposed to be a Basepart. You declared it as a motor6D

how would i change it?
( character requirement )

He means change the variable. If pickaxehitbox is referenced to “MyModel.PickAxeMotor6D” for example, then you’d want to change the variable to “MyModel.ActualPickAxe” for another example.

local Tool = script.Parent
local Pickaxehitbox = Pickaxe.Pickaxepart.Hitbox -- Motor6D.
-- Since it's a Motor6D, then I'd want to change it to...
local Pickaxehitbox = Pickaxe.Pickaxepart.Axe

If the Motor6D is also named Hitbox, then the script will think the hitbox is a Motor6D.

but it is already referencing the actual pickaxe
image

Try naming the hitbox “PickaxeHitbox”, or change the name of the Motor6D. You probably have both the Motor6D and hitbox under the same name.

1 Like

ty it works now! (character requirement)

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