How to tween both position and rotation of a model independantly of one another?

I have humanoid models that I want to sort of run off the screen very quickly. I was planning on having the model turn sharply, then over a longer period of time (and with a different easing style) move away in the direction they turned to. However, since you can’t tween the CFrame of a model twice at the same time, this is impossible for me as far as I’m concerned.

local avatars = Workspace.Avatars:GetChildren()
				for i = 1, #avatars do
					if avatars[i] ~= highlightedAvatar then
						local scramPos = Vector3.new((math.random(0,1)*400)-200, 3, math.floor(((avatars[i].Id.Value-1)/5))*15+math.random(-100,100))
						local scramRotate = CFrame.lookAt(avatars[i].PrimaryPart.CFrame.Position, scramPos)
						
						local hum = avatars[i]:WaitForChild("Humanoid")
						local track = hum:LoadAnimation(avatars[i].Animate.run.RunAnim)
						track.Priority = Enum.AnimationPriority.Action4
						track:Play()
						
						local tween = TweenService:Create(avatars[i].PrimaryPart, TweenInfo.new(scramTime, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {CFrame = CFrame.new(scramPos)*scramRotate})
						tween:Play()
					end
				end

This is my current solution but the issue is that the tween is so long that the rotation barely completes before the model is completely off the screen. I tried using two separate tweens but only one would actually play.

Is there any way I can get around this?

1 Like

You could try using CFrameValues to hold the position and rotation (use one for each) and then use TweenService to animate those.

When ever its value changes, set the rig’s CFrame using a new CFrame object assigned the current value of both CFrameValues.

ex:

CFrame.new(positionValue.Value.Position, rotationValue.Value) --//Create new CFrame using stored position and rotation

Hope it helps. :slight_smile:

3 Likes

If you are using Humanoids, why are you not just issuing a MoveTo command?

1 Like

This is me being an idiot I appreciate the help @C_Sharper regardless

I was dealing mostly with specific movement and rotation with the avatars so I completely disregarded :MoveTo()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.