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

Any way I can make a BodyPosition go in front of a player?

Asked by 9 years ago

So earlier I was making a boomerang tool and I fixed a few errors before I wanted to get to this part. I am using a BodyPosition to make the boomerang fly forwards. I tried using LookVector but I'm not sure how that would work in this situation.

Tool = script.Parent

function onActivated()
    wait()
    Tool.Handle.BodyPosition.position = Tool.Parent.Torso.Position + Vector3.new (20,0,0)-- I want this to be 20 studs away from where the Player is faceing but I don't know how.
    Tool.Parent = game.Workspace
end

Tool.Equipped:connect(onActivated)

Thanks! ~Minikitkat

0
That doesn't make sense, BodyPosition goes into a part. BSIncorporated 640 — 9y
0
The bodyPosition is in the handle. I am making the handle use the BodyPosition to go infront of the player. Also why is this marked as a bad post. It didn't break any rules! minikitkat 687 — 9y
0
Oh ok, (read roblox message, dont bother with the second paragraph) This won't work because the "handle" is connected to the player. So the body position will move the entire player. BSIncorporated 640 — 9y
0
It works because I tested it and it makes the tool go into the workspace and go to the position but I need it to go directly infront of the player. not just somewhere on the X axis minikitkat 687 — 9y
0
Ohh, I have no clue how to get the direction a player is facing, sorry BSIncorporated 640 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

If you have a lookVector (ex of the user's torso), simply multiply it by the magnitude you want (20 in this case) and add it to the player's torso's position:

Tool.Handle.BodyPosition.position = Tool.Parent.Torso.Position + Tool.Parent.Torso.CFrame.lookVector * 20

0
Oh I see! I was putting something completely different. Thanks!!! minikitkat 687 — 9y
Ad

Answer this question