Model Slowly Pulls Itself Apart When :SetPrimaryPartCFrame() Is Called Thousands Of Times

Describe the bug. Describe what is happening when the bug occurs. Describe what you would normally expect to occur.

  • On models that I have using SetPrimaryPartCFrame() on to move, I’ve notices gaps starting to grow between the parts.

How often does the bug happen (Everytime/sometimes/rarely)? What are the steps that reproduce the bug? Please list them in very high detail. Provide simple example places that exhibit the bug and provide description of what you believe should be the behavior.

  • This bug has been happening all the time.

  • Here are some steps to reproduce the bug:

  1. Create a model with multiple parts and set one of the parts as it’s PrimaryPart
  2. Use SetPrimaryPartCFrame() to move the model a short distance
  3. Repeat step 2. thousands of times

Where does the bug happen (www, gametest, etc) Is it level-specific? Is it game specific? Please post a link to the place that exhibits the issue.

  • This bug happens both in studio and in game.

  • Here are some places where I have noticed this bug:

  1. Giant Dipper - Roblox
  2. CFrame Coaster Tests - Roblox
  • This place regenerates the model when it reaches the station, so you’ll notice the difference from a fresh model.

Would a screenshot or video help describe it to someone? If so, post one.

For graphics bugs, it is sometimes helpful to know your system specs, especially graphics card.

  • N/A

When did the bug start happening? If we can tie it to a specific release that helps us figure out what we broke.

  • This has been happening ever since about December 2016 when I first figured out how to smoothly move models with SetPrimaryPartCFrame() and it has still been happening.

Anything else that you would want to know about the bug if it were your job to find and fix it.

  • I’d like to know if this is just due to the inaccuracies of floats or rounding.
6 Likes

This is caused by floating point precision errors when the offsets to the primarypart are calculated, which happens every call. I can’t recall if it was an official statement or not but it was mentioned in a thread a while back that SetPrimaryPartCFrame wasn’t intended to be used like this.

Using Welds (or Motor6D joints, I can’t remember) is the way to get around this. You can still keep the model anchored and CFrame it around you just need that joint object to calculate and then permanently set offsets.

2 Likes

You can also calculate the offsets of each part when the game starts, then make a custom SetPrimaryPartCFrame function to move each part’s CFrame by those amounts.

I already tried (Manual) Welds, but I’ll try Motor6Ds.

@EchoReaper Originally brought this up.

1 Like

Yep: https://devforum.roblox.com/t/setprimarypartcframe-gradually-offsets-component-parts/16041