function CreateBullet(t)local N=Gun.Main.CFrame.p local M=(S.BulletSize.X*S.BulletSize.Y)*S.BulletSize.Z local p=CF(N,N+t)local L=Instance.new("\080\097\114\116")L.BrickColor=S.BulletColor L.Name="\066\117\108\108\101\116"L.CanCollide=false L.FormFactor="\067\117\115\116\111\109"L.Size=S.BulletSize L.BottomSurface="\083\109\111\111\116\104"L.TopSurface="\083\109\111\111\116\104"local f=Instance.new("\066\108\111\099\107\077\101\115\104")f.Scale=S.BulletMeshSize f.Parent=L local I=Instance.new("\066\111\100\121\070\111\114\099\101")I.force=VEC3(0,M*(196.2-S.BulletDropPerSecond),0)I.Parent=L L.Parent=Gun_Ignore L.CFrame=p+t*3 L.Velocity=t*S.BulletVelocity return L end function CreateBulletHole(t,N)local M=GetHitSurfaceCFrame(t,N)local p=CF(N.CFrame.p,M.p)local L=(p.lookVector*(N.CFrame.p-M.p).magnitude)/2 local f=(t-M.p)+L local I=(p+L)+f local i=Instance.new("\080\097\114\116")i.BrickColor=BrickColor.new("\066\108\097\099\107")i.Transparency=1 i.Anchored=true i.CanCollide=false i.FormFactor="\067\117\115\116\111\109"i.Size=VEC3(1,1,.2)i.TopSurface=0 i.BottomSurface=0 local u=Instance.new("\066\108\111\099\107\077\101\115\104")u.Offset=VEC3(0,0,-0.05)u.Scale=VEC3(S.BulletHoleSize,S.BulletHoleSize,0)u.Parent=i local d=Instance.new("\068\101\099\097\108")d.Face=Enum.NormalId.Front d.Texture=S.BulletHoleTexture d.Parent=i i.Parent=Gun_Ignore i.CFrame=I if not N.Anchored then local t=Instance.new("\087\101\108\100",i)t.Part0=N t.Part1=i t.C0=N.CFrame:toObjectSpace(I)i.Anchored=false end delay(S.BulletHoleVisibleTime,function()if S.BulletHoleDisappearTime>0 then local t=0 while true do if t==90 then break end if not Selected then break end local N=t+1.5/S.BulletHoleDisappearTime t=N>90 and 90 or N local M=t/90 d.Transparency=NumLerp(0,1,M)RS:wait()end i:Destroy()else i:Destroy()end end)end function CreateShockwave(t,N)local M=Instance.new("\080\097\114\116")M.BrickColor=S.ShockwaveColor M.Material=Enum.Material.SmoothPlastic M.Name="\083\104\111\099\107\119\097\118\101"M.Anchored=true M.CanCollide=false M.FormFactor=Enum.FormFactor.Symmetric M.Size=VEC3(1,1,1)M.BottomSurface=Enum.SurfaceType.Smooth M.TopSurface=Enum.SurfaceType.Smooth local p=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")p.MeshType=Enum.MeshType.Sphere p.Scale=VEC3()p.Parent=M M.Parent=Gun_Ignore M.CFrame=CF(t)spawn(function()for t=0,1,1/(60*S.ShockwaveDuration)do local L=(2*N)*t p.Scale=VEC3(L,L,L)M.Transparency=t RS:wait()end M:Destroy()end)end
--------------------[ TEXTURE CREATION FUNCTIONS ]------------------------------------

function CreateBullet(Direction)
	local Origin = Gun.Main.CFrame.p
	local BulletMass = S.BulletSize.X * S.BulletSize.Y * S.BulletSize.Z
	local BulletCF = CF(Origin, Origin + Direction)
	local Bullet = Instance.new("Part")
	Bullet.BrickColor = S.BulletColor
	Bullet.Name = "Bullet"
	Bullet.CanCollide = false
	Bullet.FormFactor = "Custom"
	Bullet.Size = S.BulletSize
	Bullet.BottomSurface = "Smooth"
	Bullet.TopSurface = "Smooth"
	local Mesh = Instance.new("BlockMesh")
	Mesh.Scale = S.BulletMeshSize
	Mesh.Parent = Bullet
	local BF = Instance.new("BodyForce")
	BF.force = VEC3(0, BulletMass * (196.2 - S.BulletDropPerSecond), 0)
	BF.Parent = Bullet
	Bullet.Parent = Gun_Ignore
	Bullet.CFrame = BulletCF + Direction * 3
	Bullet.Velocity = Direction * S.BulletVelocity
	return Bullet
end

function CreateBulletHole(HitPos, HitObj)
	local SurfaceCF = GetHitSurfaceCFrame(HitPos, HitObj)
	local SurfaceDir = CF(HitObj.CFrame.p, SurfaceCF.p)
	local SurfaceDist = SurfaceDir.lookVector * (HitObj.CFrame.p - SurfaceCF.p).magnitude / 2
	local SurfaceOffset = HitPos - SurfaceCF.p + SurfaceDist
	local SurfaceCFrame = SurfaceDir + SurfaceDist + SurfaceOffset
	local HitMark = Instance.new("Part")
	HitMark.BrickColor = BrickColor.new("Black")
	HitMark.Transparency = 1
	HitMark.Anchored = true
	HitMark.CanCollide = false
	HitMark.FormFactor = "Custom"
	HitMark.Size = VEC3(1, 1, 0.2)
	HitMark.TopSurface = 0
	HitMark.BottomSurface = 0
	local Mesh = Instance.new("BlockMesh")
	Mesh.Offset = VEC3(0, 0, -0.05)
	Mesh.Scale = VEC3(S.BulletHoleSize, S.BulletHoleSize, 0)
	Mesh.Parent = HitMark
	local Decal = Instance.new("Decal")
	Decal.Face = Enum.NormalId.Front
	Decal.Texture = S.BulletHoleTexture
	Decal.Parent = HitMark
	HitMark.Parent = Gun_Ignore
	HitMark.CFrame = SurfaceCFrame
	if not HitObj.Anchored then
		local Weld = Instance.new("Weld", HitMark)
		Weld.Part0 = HitObj
		Weld.Part1 = HitMark
		Weld.C0 = HitObj.CFrame:toObjectSpace(SurfaceCFrame)
		HitMark.Anchored = false
	end
	delay(S.BulletHoleVisibleTime, function()
		if S.BulletHoleDisappearTime > 0 then
			local X = 0
			while true do
				if X == 90 then
					break
				end
				if not Selected then
					break
				end
				local NewX = X + (1.5 / S.BulletHoleDisappearTime)
				X = (NewX > 90 and 90 or NewX)
				local Alpha = X / 90
				Decal.Transparency = NumLerp(0, 1, Alpha)
				RS:wait()
			end
			HitMark:Destroy()
		else
			HitMark:Destroy()
		end
	end)
end

function CreateShockwave(Center, Radius)
	local Shockwave = Instance.new("Part")
	Shockwave.BrickColor = S.ShockwaveColor
	Shockwave.Material = Enum.Material.SmoothPlastic
	Shockwave.Name = "Shockwave"
	Shockwave.Anchored = true
	Shockwave.CanCollide = false
	Shockwave.FormFactor = Enum.FormFactor.Symmetric
	Shockwave.Size = VEC3(1, 1, 1)
	Shockwave.BottomSurface = Enum.SurfaceType.Smooth
	Shockwave.TopSurface = Enum.SurfaceType.Smooth
	local Mesh = Instance.new("SpecialMesh")
	Mesh.MeshType = Enum.MeshType.Sphere
	Mesh.Scale = VEC3()
	Mesh.Parent = Shockwave
	Shockwave.Parent = Gun_Ignore
	Shockwave.CFrame = CF(Center)
	spawn(function()
		for i = 0, 1, (1 / (60 * S.ShockwaveDuration)) do
			local Scale = 2 * Radius * i
			Mesh.Scale = VEC3(Scale, Scale, Scale)
			Shockwave.Transparency = i
			RS:wait()
		end
		Shockwave:Destroy()
	end)
end
