Viewmodel glitches when gun shooting automatically

This definetly has something to do with the renderstepped loop, when i put mode to semi and spam shot it it worked fine. here is video showing automatic, you see the viewmodel glitching out a bit.

Userinputservice.InputBegan:Connect(function(Input, Gameprocessed)
	if ToolEquipped == true and Firemode ~= nil and Firemode == "Auto" and not Gameprocessed and Input.UserInputType == Enum.UserInputType.MouseButton1 then		
		HoldingAutoButton = true			
	end
	
	if ToolEquipped == true and Firemode ~= nil and Firemode == "Semi" and not Gameprocessed and Input.UserInputType == Enum.UserInputType.MouseButton1 then
		Shootgun()
	end
end)

runservice loop:

game:GetService("RunService").RenderStepped:Connect(function(DeltaTime)
	
	if HoldingAutoButton == true then
		local CurrentTick = tick()	
		if (CurrentTick - LastTimeFired) >= Firerate then
			LastTimeFired = CurrentTick
			print("ye")
			Shootgun()			
		end
	end

shootgun function:

local function Shootgun()
	task.spawn(RecoilCamera)

	ViewmodelFireAnimation:Play()
	FireAnimation:Play()
	local MousePosition = Mouse.Hit.Position
	Communication:FireServer(MousePosition, Viewmodel:FindFirstChild("Barrel", true).Position)
	for i,v in next, Viewmodel.Handle.Barrel:GetChildren() do
		if v:IsA("ParticleEmitter") or v:IsA("PointLight") or v:IsA("SpotLight")or v:IsA("SurfaceLight") then
			v.Enabled = true
			task.wait(0.05)
			v.Enabled = false
		end
	end
end

while im at it, whats the best way to create an automatic gun? i want this to be server sided so i can prevent exploiting but i really dont know the best way