script.Parent.Head.CFrame = CFrame.lookAt(script.Parent.Head.Position, player.Character.Head.Position)
local shotDirection = script.Parent.HumanoidRootPart.CFrame.LookVector
--getting and positiong/parenting bullet
local bullet = game.ServerStorage.bullet:Clone()
--bullet.Position = script.Parent["Right Arm"].MeshPart.Position
bullet.CFrame = CFrame.new(script.Parent["Right Arm"].MeshPart.Position, shotDirection)
bullet.Parent = game.Workspace
--tweening bullet
local tweenInfo = TweenInfo.new(1)
local tween = tweenService:Create(bullet, tweenInfo, {CFrame = bullet.CFrame * CFrame.new(0, 0, 100)})
tween:Play()
I’m bad at math. This gives me this:
Every time. The trail my cursor is on is the bullet.
How can I correct this so that it aims in the right direction (forward, basically coming out of the gun every time)?
BONUS QUESTION
I want it to also not always be guaranteed to hit, so if there could be some kind of variation in the angle- maybe 0 to 1 studs- of where it shoots, that way it’s accuracy can be a bit wonky, that’d be great. Thanks.