Hello all, I'm relatively new to Lua programming, and was wondering how I could check if a WeldConstraint between two parts has broken, and then if it has, activate a ParticleEmitter briefly. After doing some research I found that .Active can be used to check whether a weld is active or not, and came up with this code:
local part = script.Parent
local originalPosition = part.Position
while true do
if (part.WeldConstraint.Active == false) and (part.Position.Magnitude > (originalPosition.Magnitude+1)) then
part.ParticleEmitter.Enabled = true
wait(2)
part.ParticleEmitter.Enabled = false
script:Destroy()
end
end
Unfortunately, the script does not work whatsoever. If anyone knows how else this would be possible, please let me know. Thank you.

4 comments
Hey T3, thank you so much for your reply. I tried to implement the new script that you suggested but, unfortunately, I'm having no luck with it working. I think one problem is with the use of GetPropertyChangedSignal() because I read this post (https://devforum.roblox.com/t/how-do-i-detect-if-a-weld-has-been-broken/253582) which states that WeldConstraints do not fire signals when changed.
Despite this, however, I believe the real issue lies somewhere else because after replacing the function with a while wait() loop, it still does not seem to work. I don't think there is a problem with the ParticleEmitter either because I modified it to just change the BrickColor, and nothing happens.
Okay, thanks for the info! I never knew WeldConstraint's Active property doesn't fire signals. I'll change my answer in a bit.
while task.wait()do, andwhile true do task.wait()does the same thing.