Shotgun Effect Broken

For some reason this shotgun effect for i = 1,12 do will work for this older RRP Shotgun script, but not for my newer edited one. I placed the loop code in the same spot, but it doesn’t work. Help?
Old RRP1 Shotgun Code:

if MyMouse then
for i = 1,12 do 					
local targetPoint = MyMouse.Hit.p
					local shootDirection = (targetPoint - Handle.Position).unit
					-- Adjust the shoot direction randomly off by a little bit to account for recoil
					shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
																	(0.5 - math.random()) * 2 * Spread,
																	(0.5 - math.random()) * 2 * Spread) * shootDirection
					local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
					local bullet

Newer FE Code:

if MyMouse then
				RecoilTrack:Play()
				local targetPoint = MyMouse.Hit.p
				local shootDirection = (targetPoint - Handle.Position).unit
				-- Adjust the shoot direction randomly off by a little bit to account for recoil
				shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
																(0.5 - math.random()) * 2 * Spread,
																(0.5 - math.random()) * 2 * Spread) * shootDirection
				
				Camera.CFrame = Camera.CFrame * CFrame.Angles(0.35,math.rad(0),0)
				
				local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
				local bullet

You getting any errors on your Output at all?

nothing except for this error saying i have to add an extra end after I added the for i = 1,12 do thing

That’s the problem. Add the end, and that should fix it. Anytime you use a do statement, you must add another end.

the thing is that it doesn’t work

it plays the equip animation, but nothing else works. the gun just breaks when I add the for i = 1,12 do

If that error is still appearing, then it’s because you aren’t properly implementing your loop.

for i = 1, 12 do
     -- Your code goes here.
end

like this?

for i = 1, 12 do
			if MyMouse then
				
				RecoilTrack:Play()
				
				local targetPoint = MyMouse.Hit.p
				local shootDirection = (targetPoint - Handle.Position).unit
				-- Adjust the shoot direction randomly off by a little bit to account for recoil
				shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
																(0.5 - math.random()) * 2 * Spread,
																(0.5 - math.random()) * 2 * Spread) * shootDirection
				
				Camera.CFrame = Camera.CFrame * CFrame.Angles(0.35,math.rad(0),0)
				
				local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
					local bullet
					end

Ah yes, end statements fun

You should organize your loop and end it with an end statement, you’re missing one which seems to be the case

it doesn’t seem to work. this code is a free model and its confusing

should i just post all the code

Try adding another end after your first end statement (Yeah if you can)

here’s the model of the gun. (8) P109MM - Roblox

its the same scripts as the “shotgun” one i used. the model and stats are different though.