How could I tween a model to change it's Orientation and Position?

I’m struggling to figure out how to tween a model to change it’s Orientation and Position. Tweening a model doens’t work like it normally would for a part I’d appreciate anyone who can take time out of their day to explain this to me.

6 Likes

If you want to Tween the model to set its Position and Orientation, you need to set the PrimaryPart of the model (PrimaryPart is a BasePart that controls the movement of the whole model) then use CFrame goal in the Tween. Remember to weld all of the parts into the PrimaryPart and Unanchor them!!

Here try this:

local TweenService = game:GetService("TweenService")

local Tree1 = game.Workspace.FallingTree1.PrimaryPart
local Tree2 = game.Workspace.FallingTree2.PrimaryPart
local Tree1Origin = Tree1.Position
local Tree1OriginRotation = Tree1.Orientation
local Tree2Origin = Tree2.Position
local Tree2OriginRotation = Tree2.Orientation

local Info = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0)

local Goals1 = {
	CFrame = CFrame.new(51.976, 13.373, -37.65),
}
local Goals2 = {
	CFrame = CFrame.new(20.226, 13.653, -46.473)
}
local Tween1 = TweenService:Create(Tree1, Info, Goals1)
local Tween2 = TweenService:Create(Tree2, Info, Goals2)

local Debounce = false

script.Parent.ClickDetector.MouseClick:Connect(function()
	if Debounce == false then 
		Debounce = true
		Tween1:Play()
		Tween2:Play()
		Tween1.Completed:Connect(function(playBackState)
			if playBackState == Enum.PlaybackState.Completed then 
				wait(5)
				print("reseting trees")
			end
		end)
		Debounce = false
	end
end)
9 Likes

will it matter if the rest of the model is anchored? So if i just adjust primary part everything will follow?

1 Like

Yes, the model will be tweened even if it is anchored!!

1 Like

hey man the rest of the model did not follow the primary part, only the primary part tweened. Do i need to weld everything to the primary part and unanchor everything except for the primary part?

I think you should try that method out. If it does not work I can try to provide you with more info.

If everything is welded to the primary part, it will move along if those parts are not anchored and you are tweening the CFrame, not Position

I already told him to Tween the CFrame :slight_smile:

Yup, Im just adding that those parts should be not anchored, only the primary part the one that will be tweened can be anchored

2 Likes

dang I did position and Oreintation my bad, how would I use the CFrame for orientation aswell? Heres script

local TweenService = game:GetService("TweenService")

local Tree1 = game.Workspace.FallingTree1.PrimaryPart
local Tree2 = game.Workspace.FallingTree2.PrimaryPart
local Tree1Origin = Tree1.Position
local Tree1OriginRotation = Tree1.Orientation
local Tree2Origin = Tree2.Position
local Tree2OriginRotation = Tree2.Orientation

local Info = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0)

local Goals1 = {
	Position = Vector3.new(51.976, 13.373, -37.65),
	Orientation = Vector3.new(50, 0, 0)
}
local Goals2 = {
	Position = Vector3.new(20.226, 13.653, -46.473),
	Orientation = Vector3.new(60, 0, 0)
}
local Tween1 = TweenService:Create(Tree1, Info, Goals1)
local Tween2 = TweenService:Create(Tree2, Info, Goals2)

local Debounce = false

script.Parent.ClickDetector.MouseClick:Connect(function()
	if Debounce == false then 
		Debounce = true
		Tween1:Play()
		Tween2:Play()
		Tween1.Completed:Connect(function(playBackState)
			if playBackState == Enum.PlaybackState.Completed then 
				wait(5)
				print("reseting trees")
			end
		end)
	end
end)

It’s not done yet because I haven’t finished debounce and all that but I had finished the tween and I hope you can explain or show me how I can use the CFrame to get the exact results I want here.

If you want to Tween the model to set its Position and Orientation, you need to set the PrimaryPart of the model (PrimaryPart is a BasePart that controls the movement of the whole model) then use CFrame goal in the Tween. Remember to weld all of the parts into the PrimaryPart and Unanchor them!!

Here try this:

local TweenService = game:GetService("TweenService")

local Tree1 = game.Workspace.FallingTree1.PrimaryPart
local Tree2 = game.Workspace.FallingTree2.PrimaryPart
local Tree1Origin = Tree1.Position
local Tree1OriginRotation = Tree1.Orientation
local Tree2Origin = Tree2.Position
local Tree2OriginRotation = Tree2.Orientation

local Info = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0)

local Goals1 = {
	CFrame = CFrame.new(51.976, 13.373, -37.65),
}
local Goals2 = {
	CFrame = CFrame.new(20.226, 13.653, -46.473)
}
local Tween1 = TweenService:Create(Tree1, Info, Goals1)
local Tween2 = TweenService:Create(Tree2, Info, Goals2)

local Debounce = false

script.Parent.ClickDetector.MouseClick:Connect(function()
	if Debounce == false then 
		Debounce = true
		Tween1:Play()
		Tween2:Play()
		Tween1.Completed:Connect(function(playBackState)
			if playBackState == Enum.PlaybackState.Completed then 
				wait(5)
				print("reseting trees")
			end
		end)
		Debounce = false
	end
end)
1 Like

So to do this all I needed to do was Copy the CFrame when it was in the right position to be moved to? I feel kinda stupid lol

Yes, you have to do that to make it work!!

1 Like

I should stop giving u the solution until I test my bad :sweat_smile:. So now using CFrame like that it will not move Orientation when I tried copying CFrame so it included Orientation i got an error

CFrame = CFrame.new({51.976, 12.802, -49.446}, {60, 0, 0}) 

because it got a table so it caused an error, so I then tryed it without the table and just

CFrame = CFrame.new(51.976, 12.802, -49.446)

And it only moved the Primarypart and didn’t orientate it. Since it didnt take leaves with it (it’s a tree btw) I tried unacnhoring leaves which just made them disappear and the part did the same thing it did before. So question is how can I take the leaves with the primary part (which is the bark) and orientate it?

It didn’t seem to work read my above reply

Can you please send me the video please??

and try to anchor all of the things to see if it work or not…

I think this tutorial should help you @Developer4Lifee

ik how to move a model but will this show me how to orientate it aswell?

i tryed that aswell sadly did not work