How to make an tween that takes into account the angle of entry so that the character can face forward (plus an additional issue)?

Sorry if this seems like a mess.

My intended goal/result

My intended result is as follows:

  1. I click a GUI Button that says “JOIN” which turns into “LEAVE” (DONE)

  2. Take away the player controls during “JOIN” and give it back with “LEAVE” (DONE)

  3. My character then walks onto the pad perfectly on center (Done, but not perfectly centered)

  4. My character then tweens to face the front ( front isn’t not yet clear in the first gif, look at test dummy and 2nd gif for intended result) (NOT DONE)

Issues

I only used pathfinding as a quick way to make the player character walk onto the pad from any angle by using the pathfinding service and doing ComputeAsync and WalkTo. If there is a better method please let me know.

This is as far as I got and the pathfinding doesn’t perfectly center itself on the training mat:
https://gyazo.com/9da1edabb3fa835fb480251b54c50b52

The bigger issue however is how do I take the angle of entry and tween the correct angle adjustment so that it faces the frontbar I added on this picture?

Green = Angle of Entry (can be from all angles, green beam is relative to character’s front)
Orange = The angle I want to tween to after pathfinding finishes
Yellow/Blue = top head view of a roblox noob

https://gyazo.com/130048c3fef4cc3bb3586ec9f1b6ce12

TL; DR:

  • pathfinding not perfect, stops just short of center (the + shaped mat’s position center)
  • no idea how to tween to front (orange bar) from any random angle (green bar)

Possible solutions I’m currently looking into

I’ve been looking into AlignOrientation, BodyGyro, the TELEPORT_FACE_ANGLE in the teleport script, and some trigonometry to see if this is even a triangle-based problem.

I might even be overthinking this entire problem.

I will be willing to post my pathfinding script since it would probably be edited to a pathfinding + tween script upon finding the solution to my current problem.

Potential future problem

Even if I get this solved,
I just need to figure out how to make this work for all instances of “Training Mat” but that’s for later.

UPDATE: Someone told me to look into LookVector, and I have -mostly- solved the issue:

https://gyazo.com/2a4aacec286211a6afa9a2806dee5a21

However, I need to improve my pathfinding script so it stops at the center of the pad instead of just short.

Any ideas?

So, I see that the character stops just an inch short of the centre. 1 possible quick fix would be to have the character walk forward just a smidge extra.

For the tweening of the character to face the front bar, I have a general representation of what you’d want to be doing. You’d want to Tween the CFrame of the HumanoidRootPart of your character to go from its current CFrame to a CFrame where it’s looking at the front bar. I’m sure you know that a CFrame can take 2 arguments to make it’s target point a certain direction.

local TweenService = game:GetService("TweenService")

local info = TweenInfo.new() -- you can do this part

local character = -- the character you want to tween
local HRP = character.HumanoidRootPart
local currentPos = HRP.Position -- get the current position of the HRP
local frontBarPos = -- position of the front bar or whatever you need to look towards

local tween = TweenService:Create(HRP, info, {CFrame = CFrame.new(currentPos, frontBarPos)}) -- this should create a smooth turn-around-and-look-at effect

tween:Play() -- and just play it

I hope this helps or gives you a better idea of where to go.