So I’m making a door for my game and it’s supposed to tween the door open. It does that, but it looks kinda funny because the part where it touched the wall moves as well, here’s a video
Is there any way i can fix this?
Here is the code just in case you need to see it.
script.Parent.ClickDetector.MouseClick:Connect(function()
local ts = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(2)
local properties = {
Position = Vector3.new(255.972, 3.555, -2286.432),
Orientation = Vector3.new(0, 89.72, 0)}
local created = ts:Create(script.Parent,tweeninfo,properties)
created:Play()
end)
@ArticGamerTV If you look on the door where a hinge usually is (Hinge as in real life doors, not a roblox hinge) when it swings open, it moves forward a bit. @ScriptToon Is tht what you’re talking about?
It’s because you’re not changing the orientation on a fixed point. I’d add a part to the side of the door which you rotate and stays in place. You can either weld the door to it or set it as the primary part
Well, you can create a new part on this side of the door and scroll it as same height as door but let it be more skinny like a stick. Then all you have to do is create this door a model and create this new part as primary part of this model and weld the door on primary part. Then use a TweenService on this new part (primary part) and it should work because you will have a different starting point.
You can weld every part to the part that you’re tweening.
Example
I colored the part I have every part welded to pink
Best Method
The best method is to use this function below
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
That’s not the best function to use and I would strongly advise against it. I have a list of reasons outlined why this method is bad in my tutorial on model tweening, which was linked some ways above.
While the principles are still the same in that you ideally will be moving a model by its primary part and having all other parts welded to it, stay away from SetPrimaryPartCFrame especially if you plan to use it often. It subtly tears your model apart the more you call it.