Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

position by using lookvector and forwarding with vector3.new?

Asked by
TechModel 118
2 years ago

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

Log in to vote
1
Answered by
Leamir 3138 Moderation Voter Community Moderator
2 years ago

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.

0
well thank you TechModel 118 — 2y
Ad

Answer this question