Oh i think this is it:
function GunHandler.Shoot()
if EquipedTool.Model:GetAttribute("AmmoInMag") == 0 then
if EquipedTool.Module.Effects.LoopedFireAudio then
AnimationHandler:Stop(EquipedTool.Animations,"SpinAnimation")
EquipedTool.Model.Handle.AttachmentEmitter.Fire:Stop()
EquipedTool.Model.Handle.AttachmentEmitter.WindLoop:Stop()
Events.MainEvent:FireServer("ReplicateSound","AttachmentEmitter","Stop")
end
local Empty = EquipedTool.Model.Handle.Empty:Clone()
Empty.Parent = EquipedTool.Model.Handle
Empty:Play()
Services.Debris:AddItem(Empty,Empty.TimeLength)
Events.MainEvent:FireServer("ReplicateSound","Handle","Empty")
return
end
EquipedTool.Model:SetAttribute("MuzzleSmoke",(EquipedTool.Model:GetAttribute("MuzzleSmoke") + EquipedTool.Module.Effects.MuzzleAdd))
AnimationHandler:Stop(EquipedTool.Animations, "RecoilAnimation",-1)
AnimationHandler:Play(EquipedTool.Animations, "RecoilAnimation",-1)
local Attachment = EquipedTool.Model.Handle.AttachmentEmitter
if EquipedTool.Module.Effects.EjectChamberSmoke then
EquipedTool.Model.Handle.GasEject.ParticleEmitter:Emit(math.random(5,10))
Events.MainEvent:FireServer("ReplicateGas","ParticleEmitter")
end
if EquipedTool.Module.Effects.EjectShells then
Events.MainEvent:FireServer("ReplicateShell","Ejection",EquipedTool.Module.Bullet.Casing,EquipedTool.Model.Handle.Ejection.WorldCFrame)
if UserSettings():GetService("UserGameSettings").SavedQualityLevel.Value >= 3 then
local ShellClone = GunAssets.Casings[EquipedTool.Module.Bullet.Casing]:Clone()
ShellClone.Parent = workspace.Ignore
ShellClone.CFrame = EquipedTool.Model.Handle.Ejection.WorldCFrame
ShellClone.Velocity = (ShellClone.CFrame * CFrame.Angles(math.rad(math.random(-2,2)),math.rad(math.random(-2,2)),math.rad(math.random(-2,2)))).LookVector * 35
local AngularVelocity = Instance.new("BodyAngularVelocity")
AngularVelocity.Parent = ShellClone
AngularVelocity.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
AngularVelocity.P = math.huge
AngularVelocity.AngularVelocity = Vector3.new(math.random(), math.random(), math.random()) * 70
Services.Debris:AddItem(AngularVelocity,0.6)
Services.Debris:AddItem(ShellClone,8)
end
end
if EquipedTool.Module.Effects.LoopedFireAudio then
AnimationHandler:Play(EquipedTool.Animations,"SpinAnimation")
if not EquipedTool.Model.Handle.AttachmentEmitter.Fire.IsPlaying then
Attachment.Fire:Play()
Attachment.WindLoop:Play()
Events.MainEvent:FireServer("ReplicateSound","AttachmentEmitter","Play")
end
else
local Sound = EquipedTool.Model.Handle.AttachmentEmitter.Fire:Clone()
Sound.Parent = Attachment
Sound:Play()
Services.Debris:AddItem(Sound,4)
end
Attachment.Flash:Emit(8)
Attachment.SmokeSides:Emit(8)
Events.MainEvent:FireServer("ReplicateEffect","AttachmentEmitter",EquipedTool.Module.Effects.LoopedFireAudio)
PlayerCamera:Shake(RandomVector(EquipedTool.Module.Recoil.Min, EquipedTool.Module.Recoil.Max))
for I = 1, EquipedTool.Module.Bullet.NumberOfShots do
local ReturnInstance,ReturnedPosition,Normal,Finished = nil,nil,nil,false
local Params = RaycastParams.new()
local MousePosistion, MouseHit, MouseNormal = MousePosition.Get(Character.Rig,"Shoot")
local mdist = (MousePosistion - Attachment.WorldPosition).Magnitude
if EquipedTool.Module.Bullet.Spread then
MousePosistion += Vector3.new(math.random(-100,100)*mdist/2000,math.random(-100,100)*mdist/2000,math.random(-100,100)*mdist/2000)
end
Ignore = {Character.Rig,workspace.Ignore}
Params.FilterDescendantsInstances = Ignore
local Amr = nil
while not Finished do
local Raycast = workspace:Raycast(Attachment.WorldPosition, (MousePosistion - Attachment.WorldPosition) * 5000, Params)
if not Raycast or ((Raycast.Instance.CanCollide and Raycast.Instance.Name ~= "Armour") or (Raycast.Instance.Parent:FindFirstChild("Humanoid")) and Raycast.Instance.Name ~= "HumanoidRootPart") then
Finished = true
if Raycast then
ReturnInstance,ReturnedPosition,Normal = Raycast.Instance,Raycast.Position,Raycast.Normal
CreateEffect("Particle",Raycast.Instance,Raycast.Position,Raycast.Normal)
Events.MainEvent:FireServer("ReplicateTracer",ReturnInstance,ReturnedPosition,Normal,nil)
else
ReturnedPosition = Attachment.WorldPosition + (MousePosistion - Attachment.WorldPosition) * 5000
end
else
if Raycast.Instance.Name == "Armour" then
local Level,Health = Raycast.Instance:GetAttribute("Level"),Raycast.Instance:GetAttribute("Health")
if EquipedTool.Module.Bullet.ArmourPenValue >= Level and Health > 0 then
Amr = Health
CreateHitmarker("ArmourThrough")
elseif EquipedTool.Module.Bullet.ArmourPenValue <= Level and Health > 0 then
Finished = true
ReturnInstance,ReturnedPosition,Normal = Raycast.Instance,Raycast.Position,Raycast.Normal
CreateHitmarker("ArmourStop")
end
CreateEffect("Particle",Raycast.Instance,Raycast.Position,Raycast.Normal)
Events.MainEvent:FireServer("ReplicateTracer",Raycast.Instance,Raycast.Position,Raycast.Normal,nil)
Events.MainEvent:FireServer("Armour",Raycast.Instance,EquipedTool.Module.Damages.Torso,EquipedTool.Module.Bullet.ArmourPenValue)
end
if Raycast.Instance.Transparency ~= 1 and Raycast.Instance.Name ~= "Armour" then
CreateEffect("Particle",Raycast.Instance,Raycast.Position,Raycast.Normal)
Events.MainEvent:FireServer("ReplicateTracer",Raycast.Instance,Raycast.Position,Raycast.Normal,nil)
end
table.insert(Ignore,Raycast.Instance)
Params.FilterDescendantsInstances = Ignore
end
end
coroutine.resume(coroutine.create(function()
local NewTracer = GunAssets.Tracers.Tracer1:Clone()
NewTracer.Parent = workspace.Ignore
NewTracer.Position = Attachment.WorldPosition
NewTracer.BodyVelocity.Velocity = (ReturnedPosition - Attachment.WorldPosition).Unit * 2000
NewTracer.Trail.Transparency = NumberSequence.new{
NumberSequenceKeypoint.new(0, 1),
NumberSequenceKeypoint.new(1, 1),
}
Events.MainEvent:FireServer("ReplicateTracer",ReturnInstance,ReturnedPosition,Normal,Attachment)
if ReturnInstance and Normal then
if (ReturnedPosition - Attachment.WorldPosition).Magnitude/2000 >= 0.045 and NewTracer then
task.delay(0.045,function()
NewTracer.Trail.Transparency = NumberSequence.new{
NumberSequenceKeypoint.new(0, 0),
NumberSequenceKeypoint.new(1, 0),
}
end)
end
Services.Debris:AddItem(NewTracer,math.max(0.045,(ReturnedPosition - Attachment.WorldPosition).Magnitude/2000))
elseif not ReturnInstance then
if NewTracer then
task.delay(0.045,function()
NewTracer.Trail.Transparency = NumberSequence.new{
NumberSequenceKeypoint.new(0, 0),
NumberSequenceKeypoint.new(1, 0),
}
end)
end
Services.Debris:AddItem(NewTracer,2)
end
if FoundHumanoid.ReturnHumanoid(ReturnInstance) then
local Damage = nil
if ReturnInstance.Name == "Head" then
Damage = EquipedTool.Module.Damages.Head
elseif ReturnInstance.Name == "UpperTorso" or ReturnInstance.Name == "LowerTorso" then
Damage = EquipedTool.Module.Damages.Torso
else
Damage = EquipedTool.Module.Damages.Base
end
if Amr ~= nil then
Damage -= math.sqrt(Amr)
else
CreateHitmarker("Person",ReturnInstance.Name)
end
Events.MainEvent:FireServer("DamageReplication",FoundHumanoid.ReturnHumanoid(ReturnInstance),Damage,Attachment,MousePosistion,Ignore,ReturnInstance)
end
end))
end
end