I was recently making some moving doors and came across a problem. The parts that were welded to the main door would not move if I will use the Vector3 property of the door. I did some research and found out that I must implement the movement of the door with CFrame, not Vector3. But I don’t know how to implement this movement. Can someone give me a hint?
local TS = game:GetService("TweenService")
local Info = TweenInfo.new(
0.5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
true,
0
)
local Aim = {Position = Vector3.new(-478.937, 5.85, 37.618)}
local move = TS:Create(script.Parent, Info, Aim)
move:Play()
local Aim = {CFrame = CFrame.new(-478.937, 5.85, 37.618)}
local doorTween = TS:Create(script.Parent, Info, Aim)
doorTween:Play()
Alternatively, a new CFrame can be created according to the original one.
local Aim = {CFrame = doorBase.CFrame * CFrame.new(-5,0,0)
Line above would construct a CFrame 5 studs further on the door’s X-axis. On the contrary, adding a CFrame instead of multiplying would move it by 5 studs relative to the world X-axis.
If parts in the model move improperly, that is most likely because:
Parts are anchored. | Door base should be anchored, everything else unanchored and welded to the base.
Door base orientation differs from model’s rotation.
Wow, it really worked, I don’t know why it didn’t work for me when I first tried to implement a solution by myself. Probably because of the anchored welded part1s. Anyway, as an advice from you, in order to move the door and it’s welded parts I should make the main door anchored and the welds unanchored?
Yes, that’s how I tween models. The base remains anchored so that exploiters don’t abuse delegated network ownership when near the door (intended to unburden the server of a portion of physics calculations and because clients run at 60 Hz). With that we limit the full control they would otherwise have over the door.