I am trying to do bullet spread and I think ive got it almost done im just having problems with the bullets not going to where the mouse.hit is.

Heres my code right now and also a gif of whats happening.

local Direction = CFrame.new(Tool.Barrel.CFrame.Position, Mouse.Hit.Position) * CFrame.new(math.random(-10, 10), math.random(-10, 10), math.random(-10, 10)).LookVector
								
local BulletRay = Ray.new(Tool.Barrel.CFrame.Position, Direction.Unit * 1000)

https://gyazo.com/907902b0b2e1b3e6a0969a335f69814d

Anyone have any ideas? Thank you for your time :)

3 comments

0

It's because in getting your direction, you are multiplying a CFrame by a lookVector to get a direction, which isn't a good way to find a direction. Instead, I would recommend getting the lookVector of the first CFrame and offset the Mouse.Hit position by a random number to still get that bullet spread effect. You could base the offset off of the magnitude between the tool's position and the Mouse

0

learn back math my dude

0

@LightModed You are edgy stay away from me normie.