Hello all. I was making a turret for fun, and this is one of my first times ever using LinearVelocity/BodyVelocity, so it would be a nice experiment. I want for the bullets from the turret to be able to go in the direction that it is facing via a part named “BulletDockingPos” that is stationed at the tip. However, I can’t seem to get my bullets off the ground or even moving in that general direction. Any help is appreciated, thank you.
I’m not able to help you because I’m still a beginner scripter, but to help others could you just copy/paste the code using the DevForum script? It looks like this:
Yeah, I mean put it in a DevForum script so people can understand it easier because the images with scripts always have low quality and it’s hard for people to understand it
Edit:
@RamonPIayzLinearVelocity Instances also require an Attachment to be able to assign the object from, so you’ll have to create one & Parent it within your Bullet as well
You may also have to tweak the CFrame values in order to properly get the Part to shoot in the direction of where the Turret is currently aiming
local function fireTurret()
repeat
game.Workspace.Turret.MainTurret:SetPrimaryPartCFrame(game.Workspace.Turret.MainTurret.PrimaryPart.CFrame * CFrame.Angles(0,0,math.rad(1)))
local bullet = game.ServerStorage.Bullet:Clone()
bullet.Parent = game.Workspace.Turret.Bullets
bullet.CFrame = workspace.Turret.MainTurret.BulletDockingPos.CFrame
local linearVelocity = Instance.new("LinearVelocity")
linearVelocity.Parent = bullet
linearVelocity.LineDirection = bullet.CFrame.LookVector
linearVelocity.LineVelocity = bullet.CFrame.LookVector * 2
local A = Instance.new("Attachment")
A.Parent = linearVelocity
game.Workspace.Turret.MainTurret:SetPrimaryPartCFrame(game.Workspace.Turret.MainTurret.PrimaryPart.CFrame * CFrame.Angles(0,0,math.rad(-1)))
task.wait()
until fStopped == true
end