Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

position by using lookvector and forwarding with vector3.new?

im trying to position in front of a part with 5 studs away from it. I try doing vector3.new(5) to distance it. however if i did vector3.new (0,0,5) it would move but only on the z axis. if the part was randomly rotated over the map, how can i achieve this position in front of the part at 5 studs away?

game.Players.LocalPlayer.Character.HumanoidRootPart.Position = workspace.Part.Position + (workspace.Part.CFrame.LookVector * Vector3.new(5))

1 answer

✓ Accepted answer

Hello, TechModel!

You just need to use Vector3.new(5, 5, 5). That controls the distance in all axis.

So, if you did Vector3.new(5, 0, 5), it would only use the forward and side axis, not moving the player up or down(Would make player's Y equal to part's Y).

Doing only Vector3.new(0, 5, 0) would move the player to the same position as the part, however above or below it

game.Players.LocalPlayer.Character.HumanoidRootPart.Position = workspace.Part.Position + (workspace.Part.CFrame.LookVector * Vector3.new(5, 5, 5))

If this answers your question, please mark this as the accepted answer.

1 comment

0

well thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.