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

why can't I set a body positions position properly using a parts CFrame.LookVector * n?

Asked by 3 years ago

I got this script to work using normal velocity instead of body position but now I have substituted body position for velocity because I want a constant velocity. this how ever does not work anymore and I don't know why. the bullet still comes out of the gun in the right direction but will then swerve around and will always go to the same point in the workspace. the bullet does not follow the look vectors path and instead choses a constant position in the workspace. I get no errors in the output, I am new to CFrames and body positions.

fire.OnServerEvent:Connect(function(player)
    local newBullet = bullet:Clone()
    local bp = Instance.new("BodyPosition")
    bp.MaxForce = Vector3.new(100,100,100)
    bp.D = 10
    bp.P = 100
    bp.Parent = newBullet
    newBullet.Parent = workspace
    newBullet.CFrame = barrel.CFrame + barrel.CFrame.LookVector * 3
    bp.Position = newBullet.CFrame.LookVector * 100
    debris:AddItem(newBullet, 2)
end)
0
use raycasting to detect hits and use tweenservice to move the bullet. DollorLua 235 — 3y

Answer this question