Touched event constantly firing when it's not touching

The “lilpart” part on the hammer, that is supposed to collide with the black cylinder, is saying the wheel is touching it constantly, when it is not.

Hammer Script:

local lilpart = script.Parent.Hammer.lilpart

lilpart.Touched:Connect(function()
	script.Parent.HingeConstraint.MotorMaxTorque = 100000
end)

lilpart.TouchEnded:Connect(function()
	script.Parent.HingeConstraint.MotorMaxTorque = 0
end)

ssa

More context:
This is a part of a clock movement, aka a “Chime Drum” or “Chime Barrel”. This part is supposed to activate on the quarters and spin, when the teeth on the barrel come in contact with the hammer’s tail, it will lift it up and release it once it spins over it, making it strike a bell or a chime rod.

Both are unions and are already set to PreciseConvexDecomposition.

I already tried enabling “Show Decomposition Geometry” in Studio’s settings but it didn’t really help me.

By the way, THIS is “lilpart”, it is supposed to be the hammer’s tail:
thisislilpart

2 Likes

The touched function is running everytime the part is touching any other part so you have to verify if the touched part is the right one before to run the code.

Actually, your lilpart is constantly in collision with other yellow parts, so the touched function will run non-stop.

local lilpart = script.Parent.Hammer.lilpart
local BlackCylinder = ...

lilpart.Touched:Connect(function(Hit)
    if Hit == BlackCylinder then
	    script.Parent.HingeConstraint.MotorMaxTorque = 100000
    end
end)
1 Like

Print what it’s touching, click on it in the console to figure out where it is, and handle it. Hope I helped.

1 Like

Well, there’s not really anything else in that area that can touch it, I have them on “CanTouch” and “CanQuery” disabled. Only the lilpart and the wheel have them on.

I tried it, it printes out “Wheel” (Which is the name of the gray barrel) and nothing else.

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.