lolformon
(Monsparkles19)
August 20, 2024, 2:52pm
#1
I dont fully understand how to use LinearVelocity because of the little information on Youtube.
My bullets keep flying in this particular direction (It’s not the origin) and I’m not sure why.
I have never made flying bullets before. tell me if there is a better way to do this.
local Bullet = Instance.new("Part")
Bullet.CFrame = CFrame.new(Tool.Handle.Position, Mouse.Hit.Position)
Bullet.Name = "Bullet"
Bullet.Size = Vector3.new(1,1,1)
Bullet.BrickColor = BrickColor.new(math.random(0,100))
Bullet.CanCollide = false
Bullet.Parent = Tool.Bullets
Instance.new("Highlight").Parent = Bullet
local LinearVelocity = Instance.new("LinearVelocity")
LinearVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
LinearVelocity.MaxForce = 1
local partPos = Handle.Position
local newPos = Mouse.Hit.Position
LinearVelocity.VectorVelocity = newPos - partPos
LinearVelocity.Parent = Bullet
thanks
kirbyFirer
(GargantuanPrankster8)
August 20, 2024, 3:38pm
#2
first: make sure you add an attachment to the bullet and set the Attachment0 property of the LinearVelocity to that attachment.
second: set the VectorVelocity to Bullet.CFrame.LookVector * Velocity
third: this is just a nitpick but you can use BrickColor.Random rather than math.random to get a random BrickColor.
fourth: you should use CFrame.lookAt rather than CFrame.new for making parts look at something since its an updated version.
let me know if this doesnt work.
1 Like
lolformon
(Monsparkles19)
August 20, 2024, 10:14pm
#3
thanks but it’s still isn’t working properly here is my updated code:
local Bullet = Instance.new("Part")
Bullet.CFrame = CFrame.lookAt(Tool.Handle.Position, Mouse.Hit.Position) --Changed
Bullet.Name = "Bullet"
Bullet.Size = Vector3.new(1,1,1)
Bullet.BrickColor = BrickColor.random()
Bullet.CanCollide = false
Bullet.Parent = Tool.Bullets
Instance.new("Highlight").Parent = Bullet
local attachment = Instance.new('Attachment')--Changed
attachment.Position = Vector3.new(0,0,0)--Changed
local LinearVelocity = Instance.new("LinearVelocity")
LinearVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
LinearVelocity.MaxForce = 1
LinearVelocity.VectorVelocity = Bullet.CFrame.LookVector * 1
LinearVelocity.Attachment0 = attachment--Changed
LinearVelocity.Parent = Bullet
kirbyFirer
(GargantuanPrankster8)
August 21, 2024, 11:41pm
#4
attachment was never parented to the bullet
also set the maxforce to math.huge.
and you don’t need to multiply the lookvector by 1 since that doesnt do anything.