CreateBullet Duping

I’m trying to make a gun fire two bullets at once, like a shotgun. I tried duping this line of code that’s function is to put a bullet wherever the cursor is aimed at. I want to know how to make this line of code fire more than 1 bullet (not like a machine gun, but a shotgun):

bullet = CreateBullet(bulletPos)

1 Like

Might need more code then this to fully help you out but you could use a loop to create more than 1 bullet if you have it setup that way in createbullet… something like this

local Bullets = {}
local NumBullets = 4  -- change to how many you want
for i = 1, NumBullets do
	table.insert(Bullets, CreateBullet(bulletPos))
end

for i, bullet in ipairs(Bullets) do
	-- what ever function to fire each bullet here    refer to it with bullet variable
end

for i = 1,5 do
bullet = CreateBullet(bulletPos)
end

This would create five bullets at the same time^, if that’s the way bullets are created.

But that kinda depends on how the gun works.

ive added this line of code to the CreateBullet line, and it breaks. I’ve examined another shotgun model and it has the same “for i = 1,5 do” code in it. The gun system I use is FE version of RRP2’s gun system. I also placed that onto the FE version in the exact spot where it was on the non FE. The gun system just breaks, but I don’t see anything on the output.