Touched event constantly firing when it's not touching

I have no idea what could possibly be causing it.

Try this(might need some formating):

local lilpart = script.Par  ent.Hammer.lilpart
local WantedHit = "The path of the part you want the lilpart to hit"

lilpart.Touched:Connect(function(hit)
  if hit == WantedHit then
	script.Parent.HingeConstraint.MotorMaxTorque = 100000
  end
end)

lilpart.TouchEnded:Connect(function(hit)
  if hit == WantedHit then
	script.Parent.HingeConstraint.MotorMaxTorque = 0
  end
end)
2 Likes

The problem is, the game is saying the barrel is ALWAYS touching the lilpart (or vice-versa), the spike in the barrel is supposed to touch the hammer’s tail and set its motor’s torque, and then when it ends the touch, it sets the torque to 0.

???

local lilpart = script.Parent.Hammer.lilpart

local hits = {}

lilpart.Touched:Connect(function(hit)
    if not table.find(hits, hit) then
        table.insert(hits, hit)
        script.Parent.HingeConstraint.MotorMaxTorque = 100000
    end
end)

lilpart.TouchEnded:Connect(function(hit)
    if table.find(hits, hit) then
        table.remove(hits, table.find(hits, hit))
        script.Parent.HingeConstraint.MotorMaxTorque = 0
    end
end)
1 Like

Possibly a hitbox problem? I have a feeling that the wheel may have an invisible part to it maybe.

1 Like

It only inserts “Wheel” to the table, which is the barrel.

The union is composed of a single cylinder and one triangle, which is the spike.

Perhaps the union extended the part’s hitbox. Maybe try with just a normal cylinder first to see what happens.

Even with a basic cylinder, it still seems to be constantly touching the lilpart.

Could be a problem with the Roblox Touched Event. Try looking at this Module I found:

I tried that a few days ago, it also didn’t solve my problem. Also, it seems to lag my game alot.

I really have no idea. Do you know any workarounds I can try instead of fixing the problem?

I think I have an idea, so is this like a music player or something? Is there an animation being played to move the littlepart onto the wheel? If so I think you can just edit the torque from there, then when you undo the animation you just undo the torque.

It’s not like a music player. The barrel is being moved by a HingeConstraint with a motor.

What is supposed to happen: When the spike on the barrel touches the lilpart(hammer’s tail), it is supposed to trigger the touched event for the hammer, change its maxtorque, then when it stops touching, it releases the hammer, making it strike the chime rod.

What seems to be happening: Chime barrel is apparently constantly touching the lilpart (or vice-versa).

Video demonstration of the chime barrel:

Using a HingeConstraint is one of the only ways to make this work, because touched events only work through physical movement.

Can someone please help? I don’t even know how many days it’s been since i’ve had this problem.

I’m losing my mind.

How about welding a separate invisible part to the black cylinder to act as the hitbox for the tooth?

1 Like

Even if I separate the union with just a singular cylinder without anything else, it still appears to be touching it.

Is “lil part” a union as well or is it separate from the rest of the hammer?

It is a union, and it is inside the hammer’s model.

Have you tried using a separate hitbox for both lilpart and the tooth?