If I fire while moving my character in a straight line and aiming at the same spot, the bullet spread basically does nothing at all and im not sure why?
DEMONSTRATION:
RAYCASTING CODE:
local function fire()
local mouseLocation = UserInputService:GetMouseLocation()
local viewportRay = currentCamera:ViewportPointToRay(mouseLocation.X, mouseLocation.Y)
local viewportRaycast = workspace:Raycast(viewportRay.Origin, viewportRay.Direction * travelDistance, raycastParameters)
local viewportIntersection = viewportRaycast and viewportRaycast.Position or viewportRay.Origin + viewportRay.Direction * travelDistance
local muzzlePosition = muzzleAttachment.WorldPosition
local bulletDirection = generateRandomCone((viewportIntersection - muzzlePosition).Unit, math.rad(bulletSpread)) * tool:GetAttribute("BulletTravelDistance")
local bulletRaycast = Workspace:Raycast(muzzlePosition, bulletDirection, raycastParameters)
local bulletRaycastResult = bulletRaycast and bulletRaycast.Instance
local bulletIntersection = bulletRaycast and bulletRaycast.Position or viewportIntersection
local distanceBulletTraveled = (muzzlePosition - bulletIntersection).Magnitudee
end