How do I add a listener to welded parts getting unanchored?

In my game, I have a building system that welds blocks together. Well, I want to detect all of the blocks that get disconnected (basically, blocks that are moving because they are falling over).

Now doing part:GetPropertyChangedSignal(“Position”) just doesn’t work at all for me, and I have no idea why. Part.Changed works, but it’s still not accurate. If I make a tower of 10 blocks and destroy the bottom part, it’d only pick up about 3 movements.

Now trying to set the network ownership of a block to the server that’s still connected (basically an anchored part) throws an error saying I can’t set the network owner of a part that’s anchored to the server, so how exactly does Roblox do it?

I’m not really sure what you’re trying to do, but something like:

part:GetPropertyChangedSignal(“Anchored”):Connect(function()
    if anchored then
      print(“Anchored”)
    else
      print(“Unanchored”)
    end
end

See if that works (I’m thinking you already have a system to automatically unanchor parts in this case)

1 Like

They’re being welded, not anchored.

But they’re being welded to an Anchored part? Right?
I think that you would do something like;

if weld.Part0 == mainPart then
   print(“welded”
else
   print(“not welded”)
end

You can achieve this using .ChildRemoved. (documentation)

Example:

local block = -- Path to block

block.ChildRemoved:Connect(function(removed)
    if removed.ClassName == "Weld" then
        print("Weld was removed")
    end
end)

Or, if the weld is a Descendant of the block, you can use .DescendantRemoved instead.

(My apologies if this isn’t what you’re looking for, the title and content of this post was a little confusing for me)

When a welded part becomes unanchored due to a weld breaking this means that the assembly is changing from 1 assembly into 2.

When the assembly changes the root part changes.

This is not possible to detect due to the performance reason below:

Consequently you can only detect the weld breaking or block being removed instead. To rephrase it detect the cause rather than the symptom.

Then I guess do something with the parts :GetConnectedParts to detect the unconmected and the connected.

1 Like

I’m feel like I’m getting closer to resolving the issue with :GetConnectedParts but there’s no way to listen to it.

:IsGrounded() may be helpful here. (The “ground” = anything anchored)

2 Likes

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