Can you split a union?

Hi, I was just wondering if there was any way I could split a union with a script. I’ve looked in the object browser and found nothing. Thanks for your help!

What do you mean by split a union? Like split it back into it’s individual parts or what?

Yes, separate them back. I’m making a destruction system, and I don’t want a group tons of parts into models.

I’m pretty sure if you go into the model tab you can just click separate?

Yes, but I have to do that with a script.

Hm, I’ve never tried it. It may be possible but not sure.

1 Like

I think it’s not possible to separate unions via code. I searched the documentation but didn’t find any method or property for unpacking a union or figuring out the information related to the original parts that created it. I also searched old forum topics related to this but didn’t find any solution.

Perhaps this will be added in the future or it’s a new feature missing proper documentation(maybe a service I haven’t heard of?).

For now what you can do is simply cache/clone the parts before creating said union, assuming the union is created automatically in-game. If you clone the parts you use before destroying them but don’t parent them anywhere they can be seen(basically not in workspace) physics and rendering wont be applied to them, so it should not lag players. You can take this a step further by storing them in ServerStorage so they aren’t replicated to the clients as well(until you need them that is). If you’re dealing with insane amounts of parts that may lag the server by simply being stored you can try utilizing serialization where you store the minimum information necessary to recreate them as an array or a string instead of each individual part, then you can figure out “patterns” in the data so you can compress it further if it’s needed.

2 Likes

If you can separate a union manually, you should be able to do it via script. I will suggest this feature.

1 Like

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