swatj1an
(datbeef)
September 5, 2021, 12:58am
#22
No, let me do it.
for i = 1, 3 do
bullet = CreateBullet(bulletPos)
bullet.CFrame = CFrame.new(bulletPos) * CFrame.Angles(math.rad(math.random(0,3)), math.rad(math.random(0,3)), math.rad(math.random(0,3)))
end
It’s doing the same thing you originally wrote, except it randomizes the cframe per bullet.
it didn’t create a bullet, almost like the code wasn’t even there, and then broke the gun from firing again
swatj1an
(datbeef)
September 5, 2021, 1:03am
#24
Well you’re already setting the bullet’s CFrame in the for loop, so I suggest to get rid of bullet.CFrame = bulletPos in the CreateBullet function.
local function CreateBullet(bulletPos)
wait(0.04)
local bullet = Instance.new('Part', Workspace)
bullet.FormFactor = Enum.FormFactor.Custom
bullet.Size = Vector3.new(0.1, 0.1, 0.1)
bullet.BrickColor = BrickColor.new("Black")
bullet.Shape = Enum.PartType.Block
bullet.CanCollide = false
--where the bullet.CFrame = bulletPos used to be lol
bullet.Anchored = true
bullet.TopSurface = Enum.SurfaceType.Smooth
bullet.BottomSurface = Enum.SurfaceType.Smooth
bullet.Name = 'Bullet'
DebrisService:AddItem(bullet, 3)
return bullet
end
same problem as before, it doesn’t break the gun, but also doesn’t spread the bullets out
swatj1an
(datbeef)
September 5, 2021, 1:09am
#26
Reading the code just now, it only rotates the bullet, not spread.
If you were to have spread behavior, then math.
Unfortunately, I can’t do much since I don’t make guns, but I really recommend FastCast.
Actually, you can just manipulate the position.
CFrame.new(bulletPos.X + math.random(-5, 5), bulletPos.Y, bulletPos.Z + math.random(-5, 5))
swatj1an
(datbeef)
September 5, 2021, 1:11am
#27
Although, there could be some offset, but I cba to do any math rn.