BodyVelocity according to Character Rotation

Hello! I’m pretty new to scripting and just discovered BodyVelocity. The problem is, the direction of Velocity is constant according to Position and not CFrame (which includes player rotations). Now, how would I move a part always infront of the player? I hope someone could give simple answers.

Anyways, this is the script that I used

local BVelocity = Instance.new("BodyVelocity")

if player.Character.HumanoidRootPart:FindFirstChild("Megalith") then
     BVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
     BVelocity.Velocity = player.Character.HumanoidRootPart.CFrame*CFrame.new(Vector3.new(0,0,100))
     BVelocity.Parent = player.Character.HumanoidRootPart.Megalith

“Megalith” is the part that I want to move infront of the player. The script above returns me an error, “expected Vector3, got CFrame”. I would appreciate any help, thanks.

.Velocity = root.CFrame.LookVector*speed

1 Like

i’ve changed my code into this

BVelocity.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector*Vector3.new(0,0,100)

it works when the player is facing either north or south, but facing east and west would just move the part either into North or South

Nevermind, its my fault to use Vector3. Thank you for the help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.