I'm trying to make a light part "go out" when its position changes, but for some reason my script isn't detecting a change in the part's position. It does work if I manually change the position in the properties or use the studio move tool, but when I throw some explosive at it or use :BreakJoints(), the part moves but the script doesn't detect it.
Here is the script :
for i,v in pairs(script.Parent:GetDescendants()) do -- In a folder full of parts
if v:IsA('BasePart') then
v:GetPropertyChangedSignal('Position'):Connect(function()
v.Material = Enum.Material.SmoothPlastic
v.BrickColor = BrickColor.Black()
v.PointLight.Enabled = false
end)
end
end
I tried other ways like using the .Changed event or checking the orientation but it still doesn't work. This seems like a really simple thing to do, but apparently it's giving me problems.
Also, the part is welded, not anchored, which is why I'm trying to detect its change in position.

10 comments
Position doesn't fire Changed event.
^ :GetPropertyChangedSignal() too? If so, how else can I do this?
Doesn't fire GetPropertyChangedSignal either
You could have an infinite loop if there is no event that works for it. I am sure that there would be an event but I don't know what it would be.
You could have a variable which has the value of the old position and if the current position is different then do code
^ I did do that, but it um...it didn't work, at least not correctly.
I've tested it and Position does fire on changed event
^ Well, it didn't fire for me. Did you have to manually move it or did you use an explosion to move it?
I manually moved it but ill test it
I think it's because un-anchor doesn't change property.