PrimaryPart is nil when a model with a Primary Part is copied from replicated storage

Randomly, about once every 10 game sessions, my build script will break, with the error caused by the clones of all of the models of buy-able in game furniture having no Primary Part, even though they all have Primary Parts! It’s completely random, the game will work for a while, but very occasionally this bug happens and breaks the whole build system until the player rejoins the game. When it does break it seems to happen to all the models simultaneously, and resetting the players build script won’t fix it.


The warning code is a simple:

if model.PrimaryPart == nil then
 warn()
end

All the models are copied directly out of replicated storage, the PrimaryPart is never changed, only read from. If the warning code is removed it will just error when it tries to use SetPrimaryPartCFrame, saying PrimaryPart has not been set.

6 Likes

I get this:

randomly as well - it is so weird and have never been able to repro it!

4 Likes

This would explain a bug I was having before. None of my coding changed(to my knowledge) but PrimaryParts started being nil after cloning it out of ReplicatedStorage, and unreliably so. Maybe roblox broke something approximately a month ago?

I do believe this should be in bug reports, not development support.

3 Likes

A fix for the issue may be to set the primary part again if it returns nil when copying the model directly from replicated storage.

However, if you believe this is a bug on the Roblox client, then you should defineitely post about it on the Client Bugs section so it can be looked into.

3 Likes

For me in game and in accurate play solo cloning a model that is a descendant of ReplicatedStorage removes sets its PrimaryPart property to nil on both client and server 100% of the time

Edit: it seems to be fixed after 5 minutes so false alarm

I think it started happening again last week or the week before

Even by doing so it keeps happening, i don’t know how is this possible because i verify if the clone got a PrimaryPart and if not, i clone the primary part of the reference into my model, but it keeps disappearing :confused:

I finally found an issue, it was due to the fact that to avoid wacky placements i destroyed parts touching others… so it destroyed only the Primary Part and not the entire model… If you are in a recursive function or in a loop just check carefully.