I've been tweeting models in roblox for a while now and it's always done in global space. Now trying to tween my player 5 studs forward from their current location as part of an attack move. I have no idea how to make the tween change from global to local. Is it possible to tween relative to the model?
Tweening model in relative space?
1 answer
Yeppers, of course there is. Get the player's current position like this:
local CFrame = Player.Character.PrimaryPart.CFrame;
We use CFrame in order to maintain rotation. Just think of CFrame as a Vector3 with rotation properties.
We then add the CFrame's lookvector (multiplied by a constant, which is the distance) with the CFrame's current position. The LookVector is a Vector3 value (hence Vector), which means it can be added to a CFrame value, like this:
local Formula = (CFrame.LookVector * Constant) + CFrame;
Now, you can utilize TweenService to make the tween. We don't have to worry about using :ToEulerAnglesXYZ() here because we're maintaining the rotation values by adding a Vector3 to a CFrame.
TweenService:Create(Player.Character.PrimaryPart, TweenInfo.new(0.25), {CFrame = Formula});
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Very nice. This helped me a bit, and it wasn't even my question.
Thanks so much! I didn't think to use lookvector but it makes complete sense and I can configure this to get my desired effect.