How to tween model rotation and position independently

I tested and i have to tween cframe because the rest of the model doesn’t follow if i tweened position instead even though its welded

i have it so it rotates when i press r
but when i move the model the rotation gets reset
also if i spam r the rotation gets messed up for some reason

--code for rotation
	if input.KeyCode == Enum.KeyCode.R then --rotate model
		local tween = TweenService:Create(model.PrimaryPart, tweenInfo, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(90), 0)})
		tween:Play()
		return 
	end
--code for mouse position
        local raycast = getRay(input.Position)
		if raycast then
			local tween = TweenService:Create(model.PrimaryPart, tweenInfo, {CFrame = CFrame.new(raycast.Position)})
			tween:Play()
		end

1 Like

What about instead of using Tweens for that task, just use RunService.RenderStep and change the current CFrame position and rotation over time independently with mouse and R key?

1 Like

Interesting way to put it, however that wouldn’t equate to having easing in/out tweening motion, then with runservice it would all be linearly

2 Likes

Totally agree with that. Thats a reason why I still using Tweens on many projects. But, in your case I sense that the amount of Tweens created per movement of mouse could be a little intensive, so trying RunService/Lerp approach could be helpful.

Specially when its possible to simulate Easing style/direction when using RunService and Lerping CFrames. For example check this Module which creates the easing by using lerp

2 Likes

If you just divide the timeElapsed by the totalTime, you will get a number between 0 and 1 which can be passed to tweenService:GetValue. This can be used to get easing styles easily without writing your own easing funcs/using a module.

3 Likes

There is no direct way to rotate a model using tween service, I would suggest checking this out.

1 Like