I have a door that consists of two parts which reside in a model. I am currently using SetPrimaryPartCFrame() but it is noticeable that the parts of the model don’t move together as a whole (creating a jittery effect).
What other method would I go about using to fix this issue?
You can use welds+constraints to keep the door together and move it as a whole using physics. That way Roblox takes care of properly interpolating the door for you.
The category #development-support:scripting-support is a better place for this FYI
I had the same problem recently. I was trying to use TweenService with a model but there is no possible way to do so. You have to settle with CFrame:lerp() or try what @buildthomas said.
You can create a table of all relative cframes of the door parts to a main part
In some sort of renderstepped loop, update the cframe of the main part. Then in the same frame, loop through the rest of the door parts and reference the table of relative cframes and set those cframes accordingly for each part.
I can probably come up with a code example if you have trouble seeing how this would work.
For basic users unable to view the post, I’ll post the code:
local tweenService = game:GetService("TweenService")
local info = TweenInfo.new()
local function tweenModel(model, CF)
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
local tween = tweenService:Create(CFrameValue, info, {Value = CF})
tween:Play()
tween.Completed:Connect(function()
CFrameValue:Destroy()
end)
end
I’m going to point out that if you are moving the model every frame, at some point SetPrimaryPartCFrame will run into floating point issues and parts will start offsetting into weird places.
This is why the table method is still necessary for certain cases until those issues can somehow be fixed, which I doubt it can be if a model is being rotated around and moved into all sorts of cframe orientations.