BodyVelocity Script not working correctly

Hello! I am currently encountering a problem where, whenever I run the following script, the Bullet (BasePart) goes off course.

local bodyVelocity = Instance.new("BodyVelocity", workspace.Bullet)
bodyVelocity.Velocity =  (workspace.Bullet.CFrame * CFrame.new(0,0,100)).Position
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

I also added a stud sized Part to refrence where it’s suppose to go.

However in this video where I am going to provide shows that the Bullet is going off course…

https://streamable.com/t2ki59

Do you just want the bullet to reach the target, or is that just the general direction you want it to be going?

1 Like

It’s suppose to go to that direction… The green part is suppose to be there as a REFRENCE, basically if it intersects with it then it’s going in the correct direction else not.

If your goal is to simply go in a certain direction, I would recommend doing this instead of using BodyVelocity, which is already deprecated anyway.

local RS = game:GetService("RunService")

local bullet = workspace.Bullet
local goal = workspace.Goal

local speed = 100
local direction = (goal.Position - bullet.Position).Unit
bullet.CFrame = CFrame.lookAt(bullet.Position, goal.Position)

RS.Heartbeat:Connect(function(deltaTime)
	bullet.CFrame = bullet.CFrame + (direction * deltaTime * speed)
end)
1 Like

Thank you very much! Pardon me for the late response

1 Like

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