local v=char:WaitForChild("\072\117\109\097\110\111\105\100")local s=char:WaitForChild("\072\101\097\100")local C=char:WaitForChild("\084\111\114\115\111")local S=char:WaitForChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")local F=S:WaitForChild("\082\111\111\116\074\111\105\110\116")local O=C:WaitForChild("\078\101\099\107")local Z=C:WaitForChild("\082\105\103\104\116 \083\104\111\117\108\100\101\114")local N=C:WaitForChild("\076\101\102\116 \083\104\111\117\108\100\101\114")local I=C:WaitForChild("\082\105\103\104\116 \072\105\112")local t=C:WaitForChild("\076\101\102\116 \072\105\112")local T=O.C0.Y local f=O.C0.Y local n,i=CFrame.new,CFrame.Angles local u=math.asin local k=.15 User.MouseIconEnabled=true plr.CameraMode=Enum.CameraMode.Classic cam.CameraType=Enum.CameraType.Custom cam.CameraSubject=v if gameRules.TeamTags then local v=Essential.TeamTag:clone()v.Parent=char v.Disabled=false end local M=Instance.new("\070\111\108\100\101\114",ACS_Workspace)M.Name="\067\097\115\105\110\103\115"local c=gameRules.ShellLimit local J=game:GetService("\080\104\121\115\105\099\115\083\101\114\118\105\099\101")function CreateShell(v,s)Evt.Shell:FireServer(v,s.WorldCFrame,WeaponData.EjectionOverride)end function SetWalkSpeed(v)if gameRules.WeaponWeight and(WeaponInHand and WeaponData.WeaponWeight)then if v-WeaponData.WeaponWeight<1 then(char:WaitForChild("\072\117\109\097\110\111\105\100")).WalkSpeed=1 else(char:WaitForChild("\072\117\109\097\110\111\105\100")).WalkSpeed=v-WeaponData.WeaponWeight end else(char:WaitForChild("\072\117\109\097\110\111\105\100")).WalkSpeed=v end end Evt.Shell.OnClientEvent:Connect(function(v,s,C)local S=(char.Torso.Position-s.Position).Magnitude local F if Engine.AmmoModels:FindFirstChild(v)then F=Engine.AmmoModels:FindFirstChild(v)else F=Engine.AmmoModels.Default end local O=require(F.EjectionForce)if S<100 then local S=F.Casing:Clone()S.Parent=M S.Anchored=false S.CanCollide=true S.CFrame=s*CFrame.Angles(0,math.rad(0),0)S.Name=v.."\095\067\097\115\105\110\103"S.CastShadow=false S.CustomPhysicalProperties=O.PhysProperties J:SetPartCollisionGroup(S,"\067\097\115\105\110\103\115")local Z=Instance.new("\065\116\116\097\099\104\109\101\110\116",S)Z.Position=O.ForcePoint local N=Instance.new("\086\101\099\116\111\114\070\111\114\099\101",S)N.Visible=false if C then N.Force=C else N.Force=O.CalculateForce()end N.Attachment0=Z Debris:AddItem(N,.01)if#M:GetChildren()>c then(M:GetChildren())[math.random(#M:GetChildren()/2,#M:GetChildren())]:Destroy()end if gameRules.ShellDespawn>0 then Debris:AddItem(S,gameRules.ShellDespawn)end wait(.25)if S and S:FindFirstChild("\068\114\111\112")then local v=S.Drop:Clone()v.Parent=S v.PlaybackSpeed=math.random(30,50)/40 v:Play()v.PlayOnRemove=true v:Destroy()Debris:AddItem(v,2)end end end)function handleAction(v,s,C)if PreviousTool and(canDrop and(v=="\068\114\111\112\087\101\097\112\111\110"and(s==Enum.UserInputState.Begin and gameRules.WeaponDropping)))then Evt.DropWeapon:FireServer(PreviousTool,require(PreviousTool.ACS_Settings))canDrop=false end if v=="\070\105\114\101"and(s==Enum.UserInputState.Begin and AnimDebounce)then Shoot()if WeaponData.Type=="\071\114\101\110\097\100\101"then CookGrenade=true Grenade()end elseif v=="\070\105\114\101"and s==Enum.UserInputState.End then mouse1down=false CookGrenade=false end if v=="\082\101\108\111\097\100"and(s==Enum.UserInputState.Begin and(AnimDebounce and(not CheckingMag and not reloading)))then if WeaponData.Jammed then Jammed()else Reload()end end if v=="\082\101\108\111\097\100"and(s==Enum.UserInputState.Begin and(reloading and WeaponData.ShellInsert))then CancelReload=true end if v=="\067\121\099\108\101\076\097\115\101\114"and(s==Enum.UserInputState.Begin and LaserAtt)then SetLaser()end if v=="\067\121\099\108\101\076\105\103\104\116"and(s==Enum.UserInputState.Begin and TorchAtt)then SetTorch()end if v=="\067\121\099\108\101\070\105\114\101\109\111\100\101"and(s==Enum.UserInputState.Begin and(WeaponData and WeaponData.FireModes.ChangeFiremode))then Firemode()end if v=="\067\121\099\108\101\065\105\109\112\097\114\116"and s==Enum.UserInputState.Begin then SetAimpart()end if v=="\090\101\114\111\085\112"and(s==Enum.UserInputState.Begin and(WeaponData and WeaponData.EnableZeroing))then if WeaponData.CurrentZero<WeaponData.MaxZero then WeaponInHand.Handle.Click:play()WeaponData.CurrentZero=math.min(WeaponData.CurrentZero+WeaponData.ZeroIncrement,WeaponData.MaxZero)UpdateGui()end end if v=="\090\101\114\111\068\111\119\110"and(s==Enum.UserInputState.Begin and(WeaponData and WeaponData.EnableZeroing))then if WeaponData.CurrentZero>0 then WeaponInHand.Handle.Click:play()WeaponData.CurrentZero=math.max(WeaponData.CurrentZero-WeaponData.ZeroIncrement,0)UpdateGui()end end if v=="\067\104\101\099\107\077\097\103"and(s==Enum.UserInputState.Begin and(not CheckingMag and(not reloading and(not runKeyDown and(AnimDebounce and WeaponData.CanCheckMag)))))then CheckMagFunction()end if v=="\084\111\103\103\108\101\066\105\112\111\100"and(s==Enum.UserInputState.Begin and CanBipod)then BipodActive=not BipodActive UpdateGui()end if v=="\078\086\071"and(s==Enum.UserInputState.Begin and not NVGdebounce)then if not plr.Character then return end local v=plr.Character:FindFirstChild("\072\101\108\109\101\116")if not v then return end local s=v:FindFirstChild("\085\112")if not s then return end NVGdebounce=true delay(.8,function()NVG=not NVG Evt.NVG:Fire(NVG)NVGdebounce=false end)end if v=="\065\068\083"and(s==Enum.UserInputState.Begin and AnimDebounce)then if WeaponData and(WeaponData.canAim and(GunStance>-2 and(not runKeyDown and not CheckingMag)))then aimming=not aimming ADS(aimming)end if WeaponData.Type=="\071\114\101\110\097\100\101"then GrenadeMode()end end if v=="\083\116\097\110\100"and(s==Enum.UserInputState.Begin and(ChangeStance and(not Swimming and(not Sentado and(not runKeyDown and not ACS_Client:GetAttribute("\067\111\108\108\097\112\115\101\100"))))))then if Stances==2 then Crouched=true Proned=false Stances=1 CameraY=-1 Crouch()elseif Stances==1 then Crouched=false Stances=0 CameraY=0 Stand()end end if v=="\067\114\111\117\099\104"and(s==Enum.UserInputState.Begin and(ChangeStance and(not Swimming and(not Sentado and(not runKeyDown and not ACS_Client:GetAttribute("\067\111\108\108\097\112\115\101\100"))))))then if Stances==0 then Stances=1 CameraY=-1 Crouch()Crouched=true elseif Stances==1 then Stances=2 CameraX=0 CameraY=-3.25 Virar=0 Lean()Prone()Crouched=false Proned=true end end if v=="\084\111\103\103\108\101\087\097\108\107"and(s==Enum.UserInputState.Begin and(ChangeStance and not runKeyDown))then Steady=not Steady SE_GUI.MainFrame.Poses.Steady.Visible=Steady if Stances==0 then Stand()end end if v=="\076\101\097\110\076\101\102\116"and(s==Enum.UserInputState.Begin and(Stances~=2 and(ChangeStance and(not Swimming and(not runKeyDown and(CanLean and not ACS_Client:GetAttribute("\067\111\108\108\097\112\115\101\100")))))))then if Virar==0 or Virar==1 then Virar=-1 CameraX=-1.25 else Virar=0 CameraX=0 end Lean()end if v=="\076\101\097\110\082\105\103\104\116"and(s==Enum.UserInputState.Begin and(Stances~=2 and(ChangeStance and(not Swimming and(not runKeyDown and(CanLean and not ACS_Client:GetAttribute("\067\111\108\108\097\112\115\101\100")))))))then if Virar==0 or Virar==-1 then Virar=1 CameraX=1.25 else Virar=0 CameraX=0 end Lean()end if v=="\082\117\110"and(s==Enum.UserInputState.Begin and(running and not script.Parent:GetAttribute("\073\110\106\117\114\101\100")))then mouse1down=false runKeyDown=true Stand()Stances=0 Virar=0 CameraX=0 CameraY=0 Lean()if aimming then aimming=false ADS(aimming)end if not CheckingMag and(not reloading and(WeaponData and(WeaponData.Type~="\071\114\101\110\097\100\101"and(GunStance==0 or GunStance==2 or GunStance==3))))then GunStance=3 Evt.GunStance:FireServer(GunStance,AnimData)SprintAnim()end elseif v=="\082\117\110"and(s==Enum.UserInputState.End and runKeyDown)then runKeyDown=false Stand()if not CheckingMag and(not reloading and(WeaponData and(WeaponData.Type~="\071\114\101\110\097\100\101"and(GunStance==0 or GunStance==2 or GunStance==3))))then GunStance=0 Evt.GunStance:FireServer(GunStance,AnimData)IdleAnim()end end end function resetMods()ModTable.camRecoilMod.RecoilUp=1 ModTable.camRecoilMod.RecoilLeft=1 ModTable.camRecoilMod.RecoilRight=1 ModTable.camRecoilMod.RecoilTilt=1 ModTable.gunRecoilMod.RecoilUp=1 ModTable.gunRecoilMod.RecoilTilt=1 ModTable.gunRecoilMod.RecoilLeft=1 ModTable.gunRecoilMod.RecoilRight=1 ModTable.AimRM=1 ModTable.SpreadRM=1 ModTable.DamageMod=1 ModTable.minDamageMod=1 ModTable.MinRecoilPower=1 ModTable.MaxRecoilPower=1 ModTable.RecoilPowerStepAmount=1 ModTable.MinSpread=1 ModTable.MaxSpread=1 ModTable.AimInaccuracyStepAmount=1 ModTable.AimInaccuracyDecrease=1 ModTable.WalkMult=1 ModTable.MuzzleVelocity=1 end function setMods(v)ModTable.camRecoilMod.RecoilUp=ModTable.camRecoilMod.RecoilUp*v.camRecoil.RecoilUp ModTable.camRecoilMod.RecoilLeft=ModTable.camRecoilMod.RecoilLeft*v.camRecoil.RecoilLeft ModTable.camRecoilMod.RecoilRight=ModTable.camRecoilMod.RecoilRight*v.camRecoil.RecoilRight ModTable.camRecoilMod.RecoilTilt=ModTable.camRecoilMod.RecoilTilt*v.camRecoil.RecoilTilt ModTable.gunRecoilMod.RecoilUp=ModTable.gunRecoilMod.RecoilUp*v.gunRecoil.RecoilUp ModTable.gunRecoilMod.RecoilTilt=ModTable.gunRecoilMod.RecoilTilt*v.gunRecoil.RecoilTilt ModTable.gunRecoilMod.RecoilLeft=ModTable.gunRecoilMod.RecoilLeft*v.gunRecoil.RecoilLeft ModTable.gunRecoilMod.RecoilRight=ModTable.gunRecoilMod.RecoilRight*v.gunRecoil.RecoilRight ModTable.AimRM=ModTable.AimRM*v.AimRecoilReduction ModTable.SpreadRM=ModTable.SpreadRM*v.AimSpreadReduction ModTable.DamageMod=ModTable.DamageMod*v.DamageMod ModTable.minDamageMod=ModTable.minDamageMod*v.minDamageMod ModTable.MinRecoilPower=ModTable.MinRecoilPower*v.MinRecoilPower ModTable.MaxRecoilPower=ModTable.MaxRecoilPower*v.MaxRecoilPower ModTable.RecoilPowerStepAmount=ModTable.RecoilPowerStepAmount*v.RecoilPowerStepAmount ModTable.MinSpread=ModTable.MinSpread*v.MinSpread ModTable.MaxSpread=ModTable.MaxSpread*v.MaxSpread ModTable.AimInaccuracyStepAmount=ModTable.AimInaccuracyStepAmount*v.AimInaccuracyStepAmount ModTable.AimInaccuracyDecrease=ModTable.AimInaccuracyDecrease*v.AimInaccuracyDecrease ModTable.WalkMult=ModTable.WalkMult*v.WalkMult ModTable.MuzzleVelocity=ModTable.MuzzleVelocity*v.MuzzleVelocityMod end function loadAttachment(v)if not v or not v:FindFirstChild("\078\111\100\101\115")then return end if v.Nodes:FindFirstChild("\083\105\103\104\116")and WeaponData.SightAtt~=""then SightData=require(AttModules[WeaponData.SightAtt])SightAtt=AttModels[WeaponData.SightAtt]:Clone()SightAtt.Parent=v SightAtt:SetPrimaryPartCFrame(v.Nodes.Sight.CFrame)v.AimPart.CFrame=SightAtt.AimPos.CFrame reticle=SightAtt.SightMark.SurfaceGui.Border.Scope if SightData.SightZoom>0 then ModTable.ZoomValue=SightData.SightZoom end if SightData.SightZoom2>0 then ModTable.Zoom2Value=SightData.SightZoom2 end setMods(SightData)for v,s in pairs(v:GetChildren())do if s.Name~="\073\083"then continue end s.Transparency=1 end for s,C in pairs(SightAtt:GetChildren())do if not C:IsA("\066\097\115\101\080\097\114\116")then continue end Ultil.Weld(v:WaitForChild("\072\097\110\100\108\101"),C)C.Anchored=false C.CanCollide=false end end if v.Nodes:FindFirstChild("\066\097\114\114\101\108")~=nil and WeaponData.BarrelAtt~=""then BarrelData=require(AttModules[WeaponData.BarrelAtt])BarrelAtt=AttModels[WeaponData.BarrelAtt]:Clone()BarrelAtt.Parent=v BarrelAtt:SetPrimaryPartCFrame(v.Nodes.Barrel.CFrame)if BarrelAtt:FindFirstChild("\066\097\114\114\101\108\080\111\115")~=nil then v.Handle.Muzzle.WorldCFrame=BarrelAtt.BarrelPos.CFrame end Suppressor=BarrelData.IsSuppressor FlashHider=BarrelData.IsFlashHider setMods(BarrelData)for s,C in pairs(BarrelAtt:GetChildren())do if not C:IsA("\066\097\115\101\080\097\114\116")then continue end Ultil.Weld(v:WaitForChild("\072\097\110\100\108\101"),C)C.Anchored=false C.CanCollide=false end end if v.Nodes:FindFirstChild("\085\110\100\101\114\066\097\114\114\101\108")~=nil and WeaponData.UnderBarrelAtt~=""then UnderBarrelData=require(AttModules[WeaponData.UnderBarrelAtt])UnderBarrelAtt=AttModels[WeaponData.UnderBarrelAtt]:Clone()UnderBarrelAtt.Parent=v UnderBarrelAtt:SetPrimaryPartCFrame(v.Nodes.UnderBarrel.CFrame)setMods(UnderBarrelData)BipodAtt=UnderBarrelData.IsBipod if BipodAtt then CAS:BindAction("\084\111\103\103\108\101\066\105\112\111\100",handleAction,true,gameRules.ToggleBipod)end for s,C in pairs(UnderBarrelAtt:GetChildren())do if not C:IsA("\066\097\115\101\080\097\114\116")then continue end Ultil.Weld(v:WaitForChild("\072\097\110\100\108\101"),C)C.Anchored=false C.CanCollide=false end end if v.Nodes:FindFirstChild("\079\116\104\101\114")~=nil and WeaponData.OtherAtt~=""then OtherData=require(AttModules[WeaponData.OtherAtt])OtherAtt=AttModels[WeaponData.OtherAtt]:Clone()OtherAtt.Parent=v OtherAtt:SetPrimaryPartCFrame(v.Nodes.Other.CFrame)setMods(OtherData)LaserAtt=OtherData.EnableLaser TorchAtt=OtherData.EnableFlashlight if OtherData.InfraRed then IREnable=true end for s,C in pairs(OtherAtt:GetChildren())do if not C:IsA("\066\097\115\101\080\097\114\116")then continue end Ultil.Weld(v:WaitForChild("\072\097\110\100\108\101"),C)C.Anchored=false C.CanCollide=false end end end function SetLaser()if gameRules.RealisticLaser and IREnable then if not LaserActive and not IRmode then LaserActive=true IRmode=true elseif LaserActive and IRmode then IRmode=false else LaserActive=false IRmode=false end else LaserActive=not LaserActive end WeaponInHand.Handle.Click:play()UpdateGui()if LaserActive then if Pointer then return end for v,s in pairs(WeaponInHand:GetDescendants())do if not s:IsA("\066\097\115\101\080\097\114\116")or s.Name~="\076\097\115\101\114\080\111\105\110\116"then continue end local C=Instance.new("\080\097\114\116",s)C.Shape="\066\097\108\108"C.Size=Vector3.new(.2,.2,.2)C.CanCollide=false C.Color=s.Color C.Material=Enum.Material.Neon local S=Instance.new("\065\116\116\097\099\104\109\101\110\116",s)local F=Instance.new("\065\116\116\097\099\104\109\101\110\116",C)local O=Instance.new("\066\101\097\109",C)O.Transparency=NumberSequence.new(0)O.LightEmission=1 O.LightInfluence=1 O.Attachment0=S O.Attachment1=F O.Color=ColorSequence.new(s.Color)O.FaceCamera=true O.Width0=.01 O.Width1=.01 if gameRules.RealisticLaser then O.Enabled=false end Pointer=C break end else for v,s in pairs(WeaponInHand:GetDescendants())do if not s:IsA("\066\097\115\101\080\097\114\116")or s.Name~="\076\097\115\101\114\080\111\105\110\116"then continue end s:ClearAllChildren()break end Pointer=nil if gameRules.ReplicatedLaser then Evt.SVLaser:FireServer(nil,2,nil,false,WeaponTool)end end end function SetTorch()TorchActive=not TorchActive for v,s in pairs(WeaponInHand:GetDescendants())do if not s:IsA("\066\097\115\101\080\097\114\116")or s.Name~="\070\108\097\115\104\080\111\105\110\116"then continue end s.Light.Enabled=TorchActive end Evt.SVFlash:FireServer(WeaponTool,TorchActive)WeaponInHand.Handle.Click:play()UpdateGui()end function ToggleADS(v)local s if WeaponData.adsTime then s=TweenInfo.new(WeaponData.adsTime/20,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,WeaponData.adsTime/20)else s=TweenInfo.new(.2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,.2)end if v=="\082\069\071"then for v,C in pairs(WeaponInHand:GetChildren())do if C.Name=="\082\069\071"then(TS:Create(C,s,{Transparency=0})):Play()elseif C.Name=="\065\068\083"then(TS:Create(C,s,{Transparency=1})):Play()end end elseif v=="\065\068\083"then for v,C in pairs(WeaponInHand:GetChildren())do if C.Name=="\082\069\071"then(TS:Create(C,s,{Transparency=1})):Play()elseif C.Name=="\065\068\083"then(TS:Create(C,s,{Transparency=0})):Play()end end end end function ADS(v)if not WeaponData or not WeaponInHand then return end if v then if SafeMode then SafeMode=false GunStance=0 IdleAnim()UpdateGui()end;(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).MouseDeltaSensitivity=Sens/100 WeaponInHand.Handle.AimDown:Play()if WeaponData.ADSEnabled then if WeaponData.ADSEnabled[AimPartMode]then ToggleADS("\065\068\083")end else ToggleADS("\065\068\083")end GunStance=2 Evt.GunStance:FireServer(GunStance,AnimData);(TS:Create(Crosshair.Up,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Down,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Left,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Right,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Center,TweenInfo.new(.2,Enum.EasingStyle.Linear),{ImageTransparency=1})):Play()else(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).MouseDeltaSensitivity=1 WeaponInHand.Handle.AimUp:Play()ToggleADS("\082\069\071")GunStance=0 Evt.GunStance:FireServer(GunStance,AnimData)if WeaponData.CrossHair then(TS:Create(Crosshair.Up,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=0})):Play();(TS:Create(Crosshair.Down,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=0})):Play();(TS:Create(Crosshair.Left,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=0})):Play();(TS:Create(Crosshair.Right,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=0})):Play()end if WeaponData.CenterDot then(TS:Create(Crosshair.Center,TweenInfo.new(.2,Enum.EasingStyle.Linear),{ImageTransparency=0})):Play()else(TS:Create(Crosshair.Center,TweenInfo.new(.2,Enum.EasingStyle.Linear),{ImageTransparency=1})):Play()end end end function SetAimpart()if aimming then if AimPartMode==1 then AimPartMode=2 if WeaponInHand:FindFirstChild("\065\105\109\080\097\114\116\050")then CurAimpart=WeaponInHand:FindFirstChild("\065\105\109\080\097\114\116\050")end else AimPartMode=1 CurAimpart=WeaponInHand:FindFirstChild("\065\105\109\080\097\114\116")end if WeaponData.ADSEnabled then if WeaponData.ADSEnabled[AimPartMode]then ToggleADS("\065\068\083")else ToggleADS("\082\069\071")end end end end function Firemode()WeaponInHand.Handle.SafetyClick:Play()mouse1down=false if WeaponData.ShootType==1 and WeaponData.FireModes.Burst==true then WeaponData.ShootType=2 elseif WeaponData.ShootType==1 and(WeaponData.FireModes.Burst==false and WeaponData.FireModes.Auto==true)then WeaponData.ShootType=3 elseif WeaponData.ShootType==2 and WeaponData.FireModes.Auto==true then WeaponData.ShootType=3 elseif WeaponData.ShootType==2 and(WeaponData.FireModes.Semi==true and WeaponData.FireModes.Auto==false)then WeaponData.ShootType=1 elseif WeaponData.ShootType==3 and WeaponData.FireModes.Semi==true then WeaponData.ShootType=1 elseif WeaponData.ShootType==3 and(WeaponData.FireModes.Semi==false and WeaponData.FireModes.Burst==true)then WeaponData.ShootType=2 end UpdateGui()end function setup(v)if not char or not v or not char:FindFirstChild("\072\117\109\097\110\111\105\100")or char.Humanoid.Health<=0 then return end local s=v local C=GunModels:FindFirstChild(v.Name)if not s or not C then warn("\084\111\111\108 \079\114 \071\117\110 \077\111\100\101\108 \068\111\101\115\110\'\116 \069\120\105\115\116")return end ToolEquip=true User.MouseIconEnabled=false plr.CameraMode=Enum.CameraMode.LockFirstPerson WeaponTool=s if WeaponTool then PreviousTool=WeaponTool canDrop=true end WeaponData=require(v:FindFirstChild("\065\067\083\095\083\101\116\116\105\110\103\115"))AnimData=require(v:FindFirstChild("\065\067\083\095\065\110\105\109\097\116\105\111\110\115"))WeaponInHand=C:Clone()WeaponInHand.PrimaryPart=WeaponInHand:WaitForChild("\072\097\110\100\108\101")if WeaponData.Type=="\071\117\110"then WeaponInHand.Handle.AimDown:Play()end Evt.Equip:FireServer(v,1,WeaponData,AnimData)RepValues=v:WaitForChild("\082\101\112\086\097\108\117\101\115")ViewModel=(ArmModel:WaitForChild("\065\114\109\115")):Clone()ViewModel.Name="\086\105\101\119\109\111\100\101\108"if char:WaitForChild("\066\111\100\121 \067\111\108\111\114\115")then local v=(char:WaitForChild("\066\111\100\121 \067\111\108\111\114\115")):Clone()v.Parent=ViewModel end if char:FindFirstChild("\083\104\105\114\116")then local v=(char:FindFirstChild("\083\104\105\114\116")):Clone()v.Parent=ViewModel end AnimPart=Instance.new("\080\097\114\116",ViewModel)AnimPart.Size=Vector3.new(.1,.1,.1)AnimPart.Anchored=true AnimPart.CanCollide=false AnimPart.Transparency=1 ViewModel.PrimaryPart=AnimPart LArmWeld=Instance.new("\077\111\116\111\114\054\068",AnimPart)LArmWeld.Name="\076\101\102\116\065\114\109"LArmWeld.Part0=AnimPart RArmWeld=Instance.new("\077\111\116\111\114\054\068",AnimPart)RArmWeld.Name="\082\105\103\104\116\065\114\109"RArmWeld.Part0=AnimPart GunWeld=Instance.new("\077\111\116\111\114\054\068",AnimPart)GunWeld.Name="\072\097\110\100\108\101"ViewModel.Parent=cam maincf=AnimData.MainCFrame guncf=AnimData.GunCFrame larmcf=AnimData.LArmCFrame rarmcf=AnimData.RArmCFrame if WeaponData.CrossHair then(TS:Create(Crosshair.Up,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=0})):Play();(TS:Create(Crosshair.Down,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=0})):Play();(TS:Create(Crosshair.Left,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=0})):Play();(TS:Create(Crosshair.Right,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=0})):Play()if WeaponData.Bullets>1 then Crosshair.Up.Rotation=90 Crosshair.Down.Rotation=90 Crosshair.Left.Rotation=90 Crosshair.Right.Rotation=90 else Crosshair.Up.Rotation=0 Crosshair.Down.Rotation=0 Crosshair.Left.Rotation=0 Crosshair.Right.Rotation=0 end else(TS:Create(Crosshair.Up,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Down,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Left,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Right,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play()end if WeaponData.CenterDot then(TS:Create(Crosshair.Center,TweenInfo.new(.2,Enum.EasingStyle.Linear),{ImageTransparency=0})):Play()else(TS:Create(Crosshair.Center,TweenInfo.new(.2,Enum.EasingStyle.Linear),{ImageTransparency=1})):Play()end LArm=ViewModel:WaitForChild("\076\101\102\116 \065\114\109")LArmWeld.Part1=LArm LArmWeld.C0=CFrame.new()LArmWeld.C1=CFrame.new(1,-1,-5)*(CFrame.Angles(math.rad(0),math.rad(0),math.rad(0))):inverse()RArm=ViewModel:WaitForChild("\082\105\103\104\116 \065\114\109")RArmWeld.Part1=RArm RArmWeld.C0=CFrame.new()RArmWeld.C1=CFrame.new(-1,-1,-5)*(CFrame.Angles(math.rad(0),math.rad(0),math.rad(0))):inverse()GunWeld.Part0=RArm LArm.Anchored=false RArm.Anchored=false ModTable.ZoomValue=WeaponData.Zoom ModTable.Zoom2Value=WeaponData.Zoom2 IREnable=WeaponData.InfraRed CAS:BindAction("\070\105\114\101",handleAction,true,Enum.UserInputType.MouseButton1,Enum.KeyCode.ButtonR2)CAS:BindAction("\065\068\083",handleAction,true,Enum.UserInputType.MouseButton2,Enum.KeyCode.ButtonL2)CAS:BindAction("\082\101\108\111\097\100",handleAction,true,gameRules.Reload,Enum.KeyCode.ButtonB)CAS:BindAction("\067\121\099\108\101\065\105\109\112\097\114\116",handleAction,false,gameRules.SwitchSights)CAS:BindAction("\067\121\099\108\101\076\097\115\101\114",handleAction,true,gameRules.ToggleLaser)CAS:BindAction("\067\121\099\108\101\076\105\103\104\116",handleAction,true,gameRules.ToggleLight)CAS:BindAction("\067\121\099\108\101\070\105\114\101\109\111\100\101",handleAction,false,gameRules.FireMode)CAS:BindAction("\067\104\101\099\107\077\097\103",handleAction,false,gameRules.CheckMag)CAS:BindAction("\090\101\114\111\068\111\119\110",handleAction,false,gameRules.ZeroDown)CAS:BindAction("\090\101\114\111\085\112",handleAction,false,gameRules.ZeroUp)CAS:BindAction("\068\114\111\112\087\101\097\112\111\110",handleAction,true,gameRules.DropGun)loadAttachment(WeaponInHand)BSpread=math.min(WeaponData.MinSpread*ModTable.MinSpread,WeaponData.MaxSpread*ModTable.MaxSpread)RecoilPower=math.min(WeaponData.MinRecoilPower*ModTable.MinRecoilPower,WeaponData.MaxRecoilPower*ModTable.MaxRecoilPower)Ammo=RepValues.Mag.Value StoredAmmo=RepValues.StoredAmmo.Value CurAimpart=WeaponInHand:FindFirstChild("\065\105\109\080\097\114\116")for v,s in pairs(WeaponInHand:GetChildren())do if s.Name=="\087\097\114\104\101\097\100"and Ammo<1 then s.Transparency=1 end end for v,s in pairs(WeaponInHand:GetDescendants())do if s:IsA("\066\097\115\101\080\097\114\116")and s.Name=="\070\108\097\115\104\080\111\105\110\116"then TorchAtt=true end if s:IsA("\066\097\115\101\080\097\114\116")and s.Name=="\076\097\115\101\114\080\111\105\110\116"then LaserAtt=true end end if WeaponData.Type=="\071\117\110"and WeaponData.ShellEjectionMod then WeaponInHand.Bolt.SlidePull.Played:Connect(function()if Ammo>0 or canPump then CreateShell(WeaponData.BulletType,WeaponInHand.Handle.Chamber)WeaponInHand.Handle.Chamber.Smoke:Emit(10)canPump=false end end)end if WeaponData.EnableHUD then SE_GUI.GunHUD.Visible=true end UpdateGui()for v,s in pairs(WeaponInHand:GetChildren())do if s:IsA("\066\097\115\101\080\097\114\116")and s.Name~="\072\097\110\100\108\101"then if s.Name~="\066\111\108\116"and(s.Name~="\076\105\100"and s.Name~="\083\108\105\100\101")then Ultil.Weld(WeaponInHand:WaitForChild("\072\097\110\100\108\101"),s)end if s.Name=="\066\111\108\116"or s.Name=="\083\108\105\100\101"then Ultil.WeldComplex(WeaponInHand:WaitForChild("\072\097\110\100\108\101"),s,s.Name)end if s.Name=="\076\105\100"then if WeaponInHand:FindFirstChild("\076\105\100\072\105\110\103\101")then Ultil.Weld(s,WeaponInHand:WaitForChild("\076\105\100\072\105\110\103\101"))else Ultil.Weld(s,WeaponInHand:WaitForChild("\072\097\110\100\108\101"))end end end end for v,s in pairs(WeaponInHand:GetChildren())do if s:IsA("\066\097\115\101\080\097\114\116")then s.Anchored=false s.CanCollide=false end end if WeaponInHand:FindFirstChild("\078\111\100\101\115")then for v,s in pairs(WeaponInHand.Nodes:GetChildren())do if s:IsA("\066\097\115\101\080\097\114\116")then Ultil.Weld(WeaponInHand:WaitForChild("\072\097\110\100\108\101"),s)s.Anchored=false s.CanCollide=false end end end GunWeld.Part1=WeaponInHand:WaitForChild("\072\097\110\100\108\101")GunWeld.C1=guncf WeaponInHand.Parent=ViewModel if Ammo<=0 and WeaponData.Type=="\071\117\110"then WeaponInHand.Handle.Slide.C0=WeaponData.SlideEx:inverse()end EquipAnim()if WeaponData and WeaponData.Type~="\071\114\101\110\097\100\101"then RunCheck()end end function unset()ToolEquip=false Evt.Equip:FireServer(WeaponTool,2)CAS:UnbindAction("\070\105\114\101")CAS:UnbindAction("\065\068\083")CAS:UnbindAction("\082\101\108\111\097\100")CAS:UnbindAction("\067\121\099\108\101\076\097\115\101\114")CAS:UnbindAction("\067\121\099\108\101\076\105\103\104\116")CAS:UnbindAction("\067\121\099\108\101\070\105\114\101\109\111\100\101")CAS:UnbindAction("\067\121\099\108\101\065\105\109\112\097\114\116")CAS:UnbindAction("\090\101\114\111\085\112")CAS:UnbindAction("\090\101\114\111\068\111\119\110")CAS:UnbindAction("\067\104\101\099\107\077\097\103")mouse1down=false aimming=false;(TS:Create(cam,AimTween,{FieldOfView=70})):Play();(TS:Create(Crosshair.Up,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Down,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Left,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Right,TweenInfo.new(.2,Enum.EasingStyle.Linear),{BackgroundTransparency=1})):Play();(TS:Create(Crosshair.Center,TweenInfo.new(.2,Enum.EasingStyle.Linear),{ImageTransparency=1})):Play()User.MouseIconEnabled=true;(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).MouseDeltaSensitivity=1 cam.CameraType=Enum.CameraType.Custom plr.CameraMode=Enum.CameraMode.Classic if WeaponInHand then if WeaponData.Type=="\071\117\110"then local v=true if WeaponData.Jammed or Ammo<1 then v=false end Evt.RepAmmo:FireServer(WeaponTool,Ammo,StoredAmmo,WeaponData.Jammed)end ViewModel:Destroy()ViewModel=nil WeaponInHand=nil WeaponTool=nil LArm=nil RArm=nil LArmWeld=nil RArmWeld=nil WeaponData=nil AnimData=nil SightAtt=nil reticle=nil BarrelAtt=nil UnderBarrelAtt=nil OtherAtt=nil LaserAtt=false LaserActive=false IRmode=false TorchAtt=false TorchActive=false BipodAtt=false BipodActive=false LaserDist=0 Pointer=nil BSpread=nil RecoilPower=nil Suppressor=false FlashHider=false CancelReload=false reloading=false SafeMode=false CheckingMag=false GRDebounce=false CookGrenade=false GunStance=0 resetMods()generateBullet=1 AimPartMode=1 SE_GUI.GunHUD.Visible=false SE_GUI.GrenadeForce.Visible=false BipodCF=CFrame.new()if gameRules.ReplicatedLaser then Evt.SVLaser:FireServer(nil,2,nil,false,WeaponTool)end end end local G=false function HeadMovement()if gameRules.HeadMovement or WeaponInHand then if not char:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")or not char:FindFirstChild("\072\117\109\097\110\111\105\100")or char.Humanoid.Health<=0 then return end if char.Humanoid.RigType==Enum.HumanoidRigType.R15 then return end if not ACS_Client or ACS_Client:GetAttribute("\067\111\108\108\097\112\115\101\100")then return end local v=(char.HumanoidRootPart.CFrame:toObjectSpace(cam.CFrame)).lookVector if O then G=not G local s=((n(0,-0.5,0)*i(0,u(v.x)/1.15,0))*i(-u(cam.CFrame.LookVector.y)+u(char.Torso.CFrame.lookVector.Y),0,0))*i(-math.rad(90),0,math.rad(180));(TS:Create(O,TweenInfo.new(.2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0),{C1=s})):Play()if not G then return end Evt.HeadRot:FireServer(s)end elseif not gameRules.HeadMovement then local v=CFrame.new(0,-0.5,0)*CFrame.Angles(math.rad(90),math.rad(180),0);(TS:Create(O,TweenInfo.new(.2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0),{C1=v})):Play()Evt.HeadRot:FireServer(v)end end function renderCam()cam.CFrame=cam.CFrame*CFrame.Angles(cameraspring.p.x,cameraspring.p.y,cameraspring.p.z)end function renderGunRecoil()recoilcf=recoilcf*CFrame.Angles(RecoilSpring.p.x,RecoilSpring.p.y,RecoilSpring.p.z)end function Recoil()local v=(math.random(WeaponData.camRecoil.camRecoilUp[1],WeaponData.camRecoil.camRecoilUp[2])/2)*ModTable.camRecoilMod.RecoilUp local s=math.random(WeaponData.camRecoil.camRecoilLeft[1],WeaponData.camRecoil.camRecoilLeft[2])*ModTable.camRecoilMod.RecoilLeft local C=math.random(WeaponData.camRecoil.camRecoilRight[1],WeaponData.camRecoil.camRecoilRight[2])*ModTable.camRecoilMod.RecoilRight local S=math.random(-C,s)/2 local F=(math.random(WeaponData.camRecoil.camRecoilTilt[1],WeaponData.camRecoil.camRecoilTilt[2])/2)*ModTable.camRecoilMod.RecoilTilt local O=math.rad(v*RAND(1,1,.1))local Z=math.rad(S*RAND(-1,1,.1))local N=math.rad(F*RAND(-1,1,.1))local I=(math.random(WeaponData.gunRecoil.gunRecoilUp[1],WeaponData.gunRecoil.gunRecoilUp[2])/10)*ModTable.gunRecoilMod.RecoilUp local t=((math.random(-1,1)*math.random(WeaponData.gunRecoil.gunRecoilTilt[1],WeaponData.gunRecoil.gunRecoilTilt[2]))/10)*ModTable.gunRecoilMod.RecoilTilt local T=math.random(WeaponData.gunRecoil.gunRecoilLeft[1],WeaponData.gunRecoil.gunRecoilLeft[2])*ModTable.gunRecoilMod.RecoilLeft local f=math.random(WeaponData.gunRecoil.gunRecoilRight[1],WeaponData.gunRecoil.gunRecoilRight[2])*ModTable.gunRecoilMod.RecoilRight local n=math.random(-f,T)/10 local i=WeaponData.AimRecoilReduction*ModTable.AimRM if BipodActive then cameraspring:accelerate(Vector3.new(O,Z/2,0))if not aimming then RecoilSpring:accelerate(Vector3.new(math.rad((.25*I)*RecoilPower),math.rad((.25*n)*RecoilPower),math.rad(.25*t)))recoilcf=(recoilcf*CFrame.new(0,0,.1))*CFrame.Angles(math.rad((.25*I)*RecoilPower),math.rad((.25*n)*RecoilPower),math.rad((.25*t)*RecoilPower))else RecoilSpring:accelerate(Vector3.new(math.rad(((.25*I)*RecoilPower)/i),math.rad(((.25*n)*RecoilPower)/i),math.rad((.25*t)/i)))recoilcf=(recoilcf*CFrame.new(0,0,.1))*CFrame.Angles(math.rad(((.25*I)*RecoilPower)/i),math.rad(((.25*n)*RecoilPower)/i),math.rad(((.25*t)*RecoilPower)/i))end Thread:Wait(.05)cameraspring:accelerate(Vector3.new(-O,-Z/2,0))else cameraspring:accelerate(Vector3.new(O,Z,N))if not aimming then RecoilSpring:accelerate(Vector3.new(math.rad(I*RecoilPower),math.rad(n*RecoilPower),math.rad(t)))recoilcf=(recoilcf*CFrame.new(0,-0.05,.1))*CFrame.Angles(math.rad(I*RecoilPower),math.rad(n*RecoilPower),math.rad(t*RecoilPower))else RecoilSpring:accelerate(Vector3.new(math.rad((I*RecoilPower)/i),math.rad((n*RecoilPower)/i),math.rad(t/i)))recoilcf=(recoilcf*CFrame.new(0,0,.1))*CFrame.Angles(math.rad((I*RecoilPower)/i),math.rad((n*RecoilPower)/i),math.rad((t*RecoilPower)/i))end end end function CheckForHumanoid(v)local s=false local C=nil if v then if v.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")or v.Parent.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")then s=true if v.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")then C=v.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")elseif v.Parent.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")then C=v.Parent.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")end else s=false end end return s,C end function CastRay(v,s)if not v then return end local C=v.Position local S=cam.CFrame.Position local F=false local O=0 local Z=false local N local I=RaycastParams.new()I.FilterDescendantsInstances=Ignore_Model I.FilterType=Enum.RaycastFilterType.Blacklist I.IgnoreWater=true while v do Run.Heartbeat:Wait()if not v.Parent then break end C=v.Position O=(v.Position-s).Magnitude if O>7000 then v:Destroy()Z=true break end for v,s in pairs(game.Players:GetPlayers())do if Z or s==plr or not s.Character or not s.Character:FindFirstChild("\072\101\097\100")or(s.Character.Head.Position-C).magnitude>25 then continue end Evt.Whizz:FireServer(s)Evt.Suppression:FireServer(s,1,nil,nil)Z=true end N=workspace:Raycast(S,(C-S)*1,I)F=false if N then local C=N.Instance if C and C.Parent:IsA("\065\099\099\101\115\115\111\114\121")or C.Parent:IsA("\072\097\116")then for v,s in pairs(game.Players:GetPlayers())do if s.Character then for v,s in pairs(s.Character:GetChildren())do if s:IsA("\065\099\099\101\115\115\111\114\121")then table.insert(Ignore_Model,s)end end end end F=true CastRay(v,s)break end if C and C.Name=="\073\103\110\111\114\097\098\108\101"or C.Name=="\073\103\110\111\114\101"or C.Parent.Name=="\084\111\112"or C.Parent.Name=="\072\101\108\109\101\116"or C.Parent.Name=="\085\112"or C.Parent.Name=="\068\111\119\110"or C.Parent.Name=="\070\097\099\101"or C.Parent.Name=="\079\108\104\111"or C.Parent.Name=="\072\101\097\100\115\101\116"or C.Parent.Name=="\078\117\109\101\114\111"or C.Parent.Name=="\086\101\115\116"or C.Parent.Name=="\067\104\101\115\116"or C.Parent.Name=="\087\097\105\115\116"or C.Parent.Name=="\066\097\099\107"or C.Parent.Name=="\066\101\108\116"or C.Parent.Name=="\076\101\103\049"or C.Parent.Name=="\076\101\103\050"or C.Parent.Name=="\065\114\109\049"or C.Parent.Name=="\065\114\109\050"then table.insert(Ignore_Model,C)F=true CastRay(v,s)break end if C and C.Parent.Name=="\084\111\112"or C.Parent.Name=="\072\101\108\109\101\116"or C.Parent.Name=="\085\112"or C.Parent.Name=="\068\111\119\110"or C.Parent.Name=="\070\097\099\101"or C.Parent.Name=="\079\108\104\111"or C.Parent.Name=="\072\101\097\100\115\101\116"or C.Parent.Name=="\078\117\109\101\114\111"or C.Parent.Name=="\086\101\115\116"or C.Parent.Name=="\067\104\101\115\116"or C.Parent.Name=="\087\097\105\115\116"or C.Parent.Name=="\066\097\099\107"or C.Parent.Name=="\066\101\108\116"or C.Parent.Name=="\076\101\103\049"or C.Parent.Name=="\076\101\103\050"or C.Parent.Name=="\065\114\109\049"or C.Parent.Name=="\065\114\109\050"then table.insert(Ignore_Model,C.Parent)F=true CastRay(v,s)break end if C and((C.Transparency>=1 or C.CanCollide==false)and(C.Name~="\072\101\097\100"and(C.Name~="\082\105\103\104\116 \065\114\109"and(C.Name~="\076\101\102\116 \065\114\109"and(C.Name~="\082\105\103\104\116 \076\101\103"and(C.Name~="\076\101\102\116 \076\101\103"and(C.Name~="\085\112\112\101\114\084\111\114\115\111"and(C.Name~="\076\111\119\101\114\084\111\114\115\111"and(C.Name~="\082\105\103\104\116\085\112\112\101\114\065\114\109"and(C.Name~="\082\105\103\104\116\076\111\119\101\114\065\114\109"and(C.Name~="\082\105\103\104\116\072\097\110\100"and(C.Name~="\076\101\102\116\085\112\112\101\114\065\114\109"and(C.Name~="\076\101\102\116\076\111\119\101\114\065\114\109"and(C.Name~="\076\101\102\116\072\097\110\100"and(C.Name~="\082\105\103\104\116\085\112\112\101\114\076\101\103"and(C.Name~="\082\105\103\104\116\076\111\119\101\114\076\101\103"and(C.Name~="\082\105\103\104\116\070\111\111\116"and(C.Name~="\076\101\102\116\085\112\112\101\114\076\101\103"and(C.Name~="\076\101\102\116\076\111\119\101\114\076\101\103"and(C.Name~="\076\101\102\116\070\111\111\116"and(C.Name~="\065\114\109\111\114"and C.Name~="\069\083\104\105\101\108\100")))))))))))))))))))))then table.insert(Ignore_Model,C)F=true CastRay(v,s)break end if not F then v:Destroy()Z=true local C,S=CheckForHumanoid(N.Instance)HitMod.HitEffect(Ignore_Model,N.Position,N.Instance,N.Normal,N.Material,WeaponData)Evt.HitEffect:FireServer(N.Position,N.Instance,N.Normal,N.Material,WeaponData)local F=N.Instance O=(N.Position-s).Magnitude if C==true and(S.Health>0 and WeaponData)then local v=SKP_01 ..("-"..plr.UserId)if F.Name=="\072\101\097\100"or F.Parent.Name=="\084\111\112"or F.Parent.Name=="\072\101\097\100\115\101\116"or F.Parent.Name=="\079\108\104\111"or F.Parent.Name=="\070\097\099\101"or F.Parent.Name=="\078\117\109\101\114\111"then Evt.Damage:InvokeServer(WeaponTool,S,O,1,WeaponData,ModTable,nil,nil,v)elseif F.Name=="\084\111\114\115\111"or F.Name=="\085\112\112\101\114\084\111\114\115\111"or F.Name=="\076\111\119\101\114\084\111\114\115\111"or F.Parent.Name=="\067\104\101\115\116"or F.Parent.Name=="\087\097\105\115\116"or F.Name=="\082\105\103\104\116 \065\114\109"or F.Name=="\076\101\102\116 \065\114\109"or F.Name=="\082\105\103\104\116\085\112\112\101\114\065\114\109"or F.Name=="\082\105\103\104\116\076\111\119\101\114\065\114\109"or F.Name=="\082\105\103\104\116\072\097\110\100"or F.Name=="\076\101\102\116\085\112\112\101\114\065\114\109"or F.Name=="\076\101\102\116\076\111\119\101\114\065\114\109"or F.Name=="\076\101\102\116\072\097\110\100"then Evt.Damage:InvokeServer(WeaponTool,S,O,2,WeaponData,ModTable,nil,nil,v)elseif F.Name=="\082\105\103\104\116 \076\101\103"or F.Name=="\076\101\102\116 \076\101\103"or F.Name=="\082\105\103\104\116\085\112\112\101\114\076\101\103"or F.Name=="\082\105\103\104\116\076\111\119\101\114\076\101\103"or F.Name=="\082\105\103\104\116\070\111\111\116"or F.Name=="\076\101\102\116\085\112\112\101\114\076\101\103"or F.Name=="\076\101\102\116\076\111\119\101\114\076\101\103"or F.Name=="\076\101\102\116\070\111\111\116"then Evt.Damage:InvokeServer(WeaponTool,S,O,3,WeaponData,ModTable,nil,nil,v)end end end break end S=C end end local P=0 function TracerCalculation()if not WeaponData.Tracer and not WeaponData.BulletFlare then return false end if WeaponData.RandomTracer.Enabled then if math.random(1,100)<=WeaponData.RandomTracer.Chance then return true end return false end if P>=WeaponData.TracerEveryXShots then P=0 return true end P=P+1 return false end function CreateBullet()if WeaponData.IsLauncher then for v,s in pairs(WeaponInHand:GetChildren())do if s.Name=="\087\097\114\104\101\097\100"then s.Transparency=1 end end end local v=Instance.new("\080\097\114\116",ACS_Workspace.Client)v.Name=plr.Name.."\095\066\117\108\108\101\116"v.CanCollide=false v.Shape=Enum.PartType.Ball v.Transparency=1 v.Size=Vector3.new(1,1,1)local s=WeaponInHand.Handle.Muzzle.WorldPosition local C=WeaponInHand.Handle.Muzzle.WorldCFrame.LookVector+(WeaponInHand.Handle.Muzzle.WorldCFrame.UpVector*(((WeaponData.BulletDrop*WeaponData.CurrentZero)/4)/WeaponData.MuzzleVelocity))/2 local S=CFrame.new(s,C)local F=WeaponData.WalkMult*ModTable.WalkMult local O=Color3.fromRGB(255,255,255)local Z if aimming and WeaponData.Bullets<=1 then Z=CFrame.Angles(math.rad(RAND(-BSpread-(charspeed/1)*F,BSpread+(charspeed/1)*F)/(10*WeaponData.AimSpreadReduction)),math.rad(RAND(-BSpread-(charspeed/1)*F,BSpread+(charspeed/1)*F)/(10*WeaponData.AimSpreadReduction)),math.rad(RAND(-BSpread-(charspeed/1)*F,BSpread+(charspeed/1)*F)/(10*WeaponData.AimSpreadReduction)))else Z=CFrame.Angles(math.rad(RAND(-BSpread-(charspeed/1)*F,BSpread+(charspeed/1)*F)/10),math.rad(RAND(-BSpread-(charspeed/1)*F,BSpread+(charspeed/1)*F)/10),math.rad(RAND(-BSpread-(charspeed/1)*F,BSpread+(charspeed/1)*F)/10))end C=Z*C local N=TracerCalculation()if WeaponData.RainbowMode then O=Color3.fromRGB(math.random(0,255),math.random(0,255),math.random(0,255))else O=WeaponData.TracerColor end if N then if gameRules.ReplicatedBullets then Evt.ServerBullet:FireServer(s,C,WeaponData,ModTable)end if WeaponData.Tracer==true then local s=Instance.new("\065\116\116\097\099\104\109\101\110\116")s.Name="\065\116\049"s.Position=Vector3.new(-0.05,0,0)s.Parent=v local C=Instance.new("\065\116\116\097\099\104\109\101\110\116")C.Name="\065\116\050"C.Position=Vector3.new(.05,0,0)C.Parent=v local S=Instance.new("\084\114\097\105\108")S.Transparency=NumberSequence.new({NumberSequenceKeypoint.new(0,0,0);NumberSequenceKeypoint.new(1,1)})S.WidthScale=NumberSequence.new({NumberSequenceKeypoint.new(0,2,0),NumberSequenceKeypoint.new(1,1)})S.Color=ColorSequence.new(O)S.Texture="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\051\050\057\049\056\054\050\050"S.TextureMode=Enum.TextureMode.Stretch S.FaceCamera=true S.LightEmission=1 S.LightInfluence=0 S.Lifetime=.25 S.Attachment0=s S.Attachment1=C S.Parent=v end if WeaponData.BulletFlare==true then local s=Instance.new("\066\105\108\108\098\111\097\114\100\071\117\105",v)s.Adornee=v s.Enabled=false local C=math.random(275,375)/10 s.Size=UDim2.new(C,0,C,0)s.LightInfluence=0 local S=Instance.new("\073\109\097\103\101\076\097\098\101\108",s)S.BackgroundTransparency=1 S.Size=UDim2.new(1,0,1,0)S.Position=UDim2.new(0,0,0,0)S.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\048\052\055\048\054\054\052\048\053"S.ImageTransparency=math.random(2,5)/15 S.ImageColor3=O spawn(function()wait(.1)if not v:FindFirstChild("\066\105\108\108\098\111\097\114\100\071\117\105")then return end v.BillboardGui.Enabled=true end)end end local I=v:GetMass()local t=Vector3.new(0,I*196.2-WeaponData.BulletDrop*196.2,0)local T=Instance.new("\066\111\100\121\070\111\114\099\101",v)v.CFrame=S v:ApplyImpulse((C*WeaponData.MuzzleVelocity)*ModTable.MuzzleVelocity)T.Force=t game.Debris:AddItem(v,5)CastRay(v,s)end function meleeCast()local v local s=cam.CFrame.Position local C=cam.CFrame.LookVector*WeaponData.BladeRange local S=RaycastParams.new()S.FilterDescendantsInstances=Ignore_Model S.FilterType=Enum.RaycastFilterType.Blacklist S.IgnoreWater=true local F=workspace:Raycast(s,C,S)if F then local v=F.Instance if v and v.Parent:IsA("\065\099\099\101\115\115\111\114\121")then for v,s in pairs(game.Players:GetPlayers())do if not s.Character then continue end for v,s in pairs(s.Character:GetChildren())do if not s:IsA("\065\099\099\101\115\115\111\114\121")then continue end table.insert(Ignore_Model,s)end end return meleeCast()end if v and v.Name=="\073\103\110\111\114\097\098\108\101"or v.Name=="\073\103\110\111\114\101"or v.Parent.Name=="\084\111\112"or v.Parent.Name=="\072\101\108\109\101\116"or v.Parent.Name=="\085\112"or v.Parent.Name=="\068\111\119\110"or v.Parent.Name=="\070\097\099\101"or v.Parent.Name=="\079\108\104\111"or v.Parent.Name=="\072\101\097\100\115\101\116"or v.Parent.Name=="\078\117\109\101\114\111"or v.Parent.Name=="\086\101\115\116"or v.Parent.Name=="\067\104\101\115\116"or v.Parent.Name=="\087\097\105\115\116"or v.Parent.Name=="\066\097\099\107"or v.Parent.Name=="\066\101\108\116"or v.Parent.Name=="\076\101\103\049"or v.Parent.Name=="\076\101\103\050"or v.Parent.Name=="\065\114\109\049"or v.Parent.Name=="\065\114\109\050"then table.insert(Ignore_Model,v)return meleeCast()end if v and v.Parent.Name=="\084\111\112"or v.Parent.Name=="\072\101\108\109\101\116"or v.Parent.Name=="\085\112"or v.Parent.Name=="\068\111\119\110"or v.Parent.Name=="\070\097\099\101"or v.Parent.Name=="\079\108\104\111"or v.Parent.Name=="\072\101\097\100\115\101\116"or v.Parent.Name=="\078\117\109\101\114\111"or v.Parent.Name=="\086\101\115\116"or v.Parent.Name=="\067\104\101\115\116"or v.Parent.Name=="\087\097\105\115\116"or v.Parent.Name=="\066\097\099\107"or v.Parent.Name=="\066\101\108\116"or v.Parent.Name=="\076\101\103\049"or v.Parent.Name=="\076\101\103\050"or v.Parent.Name=="\065\114\109\049"or v.Parent.Name=="\065\114\109\050"then table.insert(Ignore_Model,v.Parent)return meleeCast()end if v and((v.Transparency>=1 or v.CanCollide==false)and(v.Name~="\072\101\097\100"and(v.Name~="\082\105\103\104\116 \065\114\109"and(v.Name~="\076\101\102\116 \065\114\109"and(v.Name~="\082\105\103\104\116 \076\101\103"and(v.Name~="\076\101\102\116 \076\101\103"and(v.Name~="\085\112\112\101\114\084\111\114\115\111"and(v.Name~="\076\111\119\101\114\084\111\114\115\111"and(v.Name~="\082\105\103\104\116\085\112\112\101\114\065\114\109"and(v.Name~="\082\105\103\104\116\076\111\119\101\114\065\114\109"and(v.Name~="\082\105\103\104\116\072\097\110\100"and(v.Name~="\076\101\102\116\085\112\112\101\114\065\114\109"and(v.Name~="\076\101\102\116\076\111\119\101\114\065\114\109"and(v.Name~="\076\101\102\116\072\097\110\100"and(v.Name~="\082\105\103\104\116\085\112\112\101\114\076\101\103"and(v.Name~="\082\105\103\104\116\076\111\119\101\114\076\101\103"and(v.Name~="\082\105\103\104\116\070\111\111\116"and(v.Name~="\076\101\102\116\085\112\112\101\114\076\101\103"and(v.Name~="\076\101\102\116\076\111\119\101\114\076\101\103"and(v.Name~="\076\101\102\116\070\111\111\116"and(v.Name~="\065\114\109\111\114"and v.Name~="\069\083\104\105\101\108\100")))))))))))))))))))))then table.insert(Ignore_Model,v)return meleeCast()end end if not F then return end local O,Z=CheckForHumanoid(F.Instance)HitMod.HitEffect(Ignore_Model,F.Position,F.Instance,F.Normal,F.Material,WeaponData)Evt.HitEffect:FireServer(F.Position,F.Instance,F.Normal,F.Material,WeaponData)local N=F.Instance if not O or Z.Health<=0 then return end local I=SKP_01 ..("-"..plr.UserId)if N.Name=="\072\101\097\100"or N.Parent.Name=="\084\111\112"or N.Parent.Name=="\072\101\097\100\115\101\116"or N.Parent.Name=="\079\108\104\111"or N.Parent.Name=="\070\097\099\101"or N.Parent.Name=="\078\117\109\101\114\111"then Thread:Spawn(function()Evt.Damage:InvokeServer(WeaponTool,Z,0,1,WeaponData,ModTable,nil,nil,I)end)elseif N.Name=="\084\111\114\115\111"or N.Name=="\085\112\112\101\114\084\111\114\115\111"or N.Name=="\076\111\119\101\114\084\111\114\115\111"or N.Parent.Name=="\067\104\101\115\116"or N.Parent.Name=="\087\097\105\115\116"or N.Name=="\082\105\103\104\116\085\112\112\101\114\065\114\109"or N.Name=="\082\105\103\104\116\076\111\119\101\114\065\114\109"or N.Name=="\082\105\103\104\116\072\097\110\100"or N.Name=="\076\101\102\116\085\112\112\101\114\065\114\109"or N.Name=="\076\101\102\116\076\111\119\101\114\065\114\109"or N.Name=="\076\101\102\116\072\097\110\100"then Thread:Spawn(function()Evt.Damage:InvokeServer(WeaponTool,Z,0,2,WeaponData,ModTable,nil,nil,I)end)elseif N.Name=="\082\105\103\104\116 \065\114\109"or N.Name=="\082\105\103\104\116 \076\101\103"or N.Name=="\076\101\102\116 \076\101\103"or N.Name=="\076\101\102\116 \065\114\109"or N.Name=="\082\105\103\104\116\085\112\112\101\114\076\101\103"or N.Name=="\082\105\103\104\116\076\111\119\101\114\076\101\103"or N.Name=="\082\105\103\104\116\070\111\111\116"or N.Name=="\076\101\102\116\085\112\112\101\114\076\101\103"or N.Name=="\076\101\102\116\076\111\119\101\114\076\101\103"or N.Name=="\076\101\102\116\070\111\111\116"then Thread:Spawn(function()Evt.Damage:InvokeServer(WeaponTool,Z,0,3,WeaponData,ModTable,nil,nil,I)end)end end function UpdateGui()if not SE_GUI or not WeaponData then return end local v=SE_GUI.GunHUD v.NText.Text=WeaponData.gunName v.BText.Text=WeaponData.BulletType v.A.Visible=SafeMode v.Att.Silencer.Visible=Suppressor v.Att.Bipod.Visible=BipodAtt v.Sens.Text=Sens/100 if WeaponData.Jammed then v.B.BackgroundColor3=Color3.fromRGB(255,0,0)else v.B.BackgroundColor3=Color3.fromRGB(255,255,255)end if Ammo>0 then v.B.Visible=true else v.B.Visible=false end if WeaponData.ShootType==1 then v.FText.Text="\083\101\109\105"elseif WeaponData.ShootType==2 then v.FText.Text="\066\117\114\115\116"elseif WeaponData.ShootType==3 then v.FText.Text="\065\117\116\111"elseif WeaponData.ShootType==4 then v.FText.Text="\080\117\109\112-\065\099\116\105\111\110"elseif WeaponData.ShootType==5 then v.FText.Text="\066\111\108\116-\065\099\116\105\111\110"end if WeaponData.EnableZeroing then v.ZeText.Visible=true v.ZeText.Text=WeaponData.CurrentZero.." \109"else v.ZeText.Visible=false end if WeaponData.MagCount then v.SAText.Text=math.ceil(StoredAmmo/WeaponData.Ammo)v.Magazines.Visible=true v.Bullets.Visible=false else v.SAText.Text=StoredAmmo v.Magazines.Visible=false v.Bullets.Visible=true end if LaserAtt then v.Att.Laser.Visible=true if LaserActive then if IRmode then(TS:Create(v.Att.Laser,TweenInfo.new(.1,Enum.EasingStyle.Linear),{ImageColor3=Color3.fromRGB(0,255,0);ImageTransparency=.123})):Play()else(TS:Create(v.Att.Laser,TweenInfo.new(.1,Enum.EasingStyle.Linear),{ImageColor3=Color3.fromRGB(255,255,255),ImageTransparency=.123})):Play()end else(TS:Create(v.Att.Laser,TweenInfo.new(.1,Enum.EasingStyle.Linear),{ImageColor3=Color3.fromRGB(255,0,0),ImageTransparency=.5})):Play()end else v.Att.Laser.Visible=false end if TorchAtt then v.Att.Flash.Visible=true if TorchActive then(TS:Create(v.Att.Flash,TweenInfo.new(.1,Enum.EasingStyle.Linear),{ImageColor3=Color3.fromRGB(255,255,255);ImageTransparency=.123})):Play()else(TS:Create(v.Att.Flash,TweenInfo.new(.1,Enum.EasingStyle.Linear),{ImageColor3=Color3.fromRGB(255,0,0);ImageTransparency=.5})):Play()end else v.Att.Flash.Visible=false end if WeaponData.Type=="\071\114\101\110\097\100\101"then SE_GUI.GrenadeForce.Visible=true else SE_GUI.GrenadeForce.Visible=false end end function CheckMagFunction()if aimming then aimming=false ADS(aimming)end if SE_GUI then local v=SE_GUI.GunHUD;(TS:Create(v.CMText,TweenInfo.new(.25,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{TextTransparency=0;TextStrokeTransparency=.75})):Play()if Ammo>=WeaponData.Ammo then v.CMText.Text="\070\117\108\108"elseif Ammo>math.floor(WeaponData.Ammo*.75)and Ammo<WeaponData.Ammo then v.CMText.Text="\078\101\097\114\108\121 \102\117\108\108"elseif Ammo<math.floor(WeaponData.Ammo*.75)and Ammo>math.floor(WeaponData.Ammo*.5)then v.CMText.Text="\065\108\109\111\115\116 \104\097\108\102"elseif Ammo==math.floor(WeaponData.Ammo*.5)then v.CMText.Text="\072\097\108\102"elseif Ammo>math.ceil(WeaponData.Ammo*.25)and Ammo<math.floor(WeaponData.Ammo*.5)then v.CMText.Text="\076\101\115\115 \116\104\097\110 \104\097\108\102"elseif Ammo<math.ceil(WeaponData.Ammo*.25)and Ammo>0 then v.CMText.Text="\065\108\109\111\115\116 \101\109\112\116\121"elseif Ammo==0 then v.CMText.Text="\069\109\112\116\121"end delay(.25,function()(TS:Create(v.CMText,TweenInfo.new(.25,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,5),{TextTransparency=1;TextStrokeTransparency=1})):Play()end)end mouse1down=false SafeMode=false GunStance=0 Evt.GunStance:FireServer(GunStance,AnimData)UpdateGui()MagCheckAnim()RunCheck()end function Grenade()if GRDebounce then return end GRDebounce=true GrenadeReady()repeat wait()until not CookGrenade TossGrenade()end function TossGrenade()if not WeaponTool or not WeaponData or not GRDebounce then return end local v=SKP_01 ..("-"..plr.UserId)GrenadeThrow()if not WeaponTool or not WeaponData then return end Evt.Grenade:FireServer(WeaponTool,WeaponData,cam.CFrame,cam.CFrame.LookVector,Power,v)unset()end function GrenadeMode()if Power>=150 then Power=100 SE_GUI.GrenadeForce.Text="\077\105\100 \084\104\114\111\119"elseif Power>=100 then Power=50 SE_GUI.GrenadeForce.Text="\076\111\119 \084\104\114\111\119"elseif Power>=50 then Power=150 SE_GUI.GrenadeForce.Text="\072\105\103\104 \084\104\114\111\119"end end function JamChance()if not WeaponData or not WeaponData.CanBreak or WeaponData.Jammed or Ammo-1<=0 then return end local v=math.random(1000)if v>2 then return end WeaponData.Jammed=true WeaponInHand.Handle.Click:Play()end function Jammed()if not WeaponData or WeaponData.Type~="\071\117\110"or not WeaponData.Jammed then return end mouse1down=false reloading=true SafeMode=false GunStance=0 Evt.GunStance:FireServer(GunStance,AnimData)UpdateGui()JammedAnim()WeaponData.Jammed=false UpdateGui()reloading=false RunCheck()end function Reload()if WeaponData.Type=="\071\117\110"and(StoredAmmo>0 and(Ammo<WeaponData.Ammo or WeaponData.IncludeChamberedBullet and Ammo<WeaponData.Ammo+1))then mouse1down=false reloading=true SafeMode=false GunStance=0 Evt.GunStance:FireServer(GunStance,AnimData)UpdateGui()if WeaponData.ShellInsert then if Ammo>0 then for v=1,WeaponData.Ammo-Ammo,1 do if StoredAmmo>0 and Ammo<WeaponData.Ammo then if CancelReload then break end ReloadAnim()Ammo=Ammo+1 StoredAmmo=StoredAmmo-1 UpdateGui()end end else TacticalReloadAnim()Ammo=Ammo+1 StoredAmmo=StoredAmmo-1 UpdateGui()for v=1,WeaponData.Ammo-Ammo,1 do if StoredAmmo>0 and(WeaponData and Ammo<WeaponData.Ammo)then if CancelReload then break end ReloadAnim()Ammo=Ammo+1 StoredAmmo=StoredAmmo-1 UpdateGui()end end end else if Ammo>0 then ReloadAnim()else TacticalReloadAnim()end if WeaponData then if Ammo-(WeaponData.Ammo-StoredAmmo)<0 then Ammo=Ammo+StoredAmmo StoredAmmo=0 elseif Ammo<=0 then StoredAmmo=StoredAmmo-(WeaponData.Ammo-Ammo)Ammo=WeaponData.Ammo elseif Ammo>0 and WeaponData.IncludeChamberedBullet then StoredAmmo=(StoredAmmo-(WeaponData.Ammo-Ammo))-1 Ammo=WeaponData.Ammo+1 elseif Ammo>0 and not WeaponData.IncludeChamberedBullet then StoredAmmo=StoredAmmo-(WeaponData.Ammo-Ammo)Ammo=WeaponData.Ammo end end end if WeaponData.Type=="\071\117\110"and WeaponData.IsLauncher then Evt.RepAmmo:FireServer(WeaponTool,Ammo,StoredAmmo,WeaponData.Jammed)end CancelReload=false reloading=false RunCheck()UpdateGui()end end function GunFx()local v=WeaponInHand.Handle.Muzzle if WeaponData.ShootType>3 then canPump=true end if Suppressor then local s=v.Supressor:Clone()s.PlaybackSpeed=s.PlaybackSpeed+math.random(-20,20)/1000 s.Parent=v s.Name="\070\105\114\105\110\103"s:Play()s.PlayOnRemove=true s:Destroy()else local s=v.Fire:Clone()s.PlaybackSpeed=s.PlaybackSpeed+math.random(-20,20)/1000 s.Parent=v s.Name="\070\105\114\105\110\103"s:Play()s.PlayOnRemove=true s:Destroy()end if v:FindFirstChild("\069\099\104\111")then local s=v.Echo:Clone()s.PlaybackSpeed=s.PlaybackSpeed+math.random(-20,20)/1000 s.Parent=v s.Name="\070\105\114\101\069\099\104\111"s:Play()s.PlayOnRemove=true s:Destroy()end if WeaponData.FlashChance and(math.random(1,10)<=WeaponData.FlashChance and not FlashHider)then if v:FindFirstChild("\070\108\097\115\104\070\088")then v.FlashFX.Enabled=true delay(.1,function()if v:FindFirstChild("\070\108\097\115\104\070\088")then v.FlashFX.Enabled=false end end)end WeaponInHand.Handle.Muzzle["\070\108\097\115\104\070\088\091\070\108\097\115\104\093"]:Emit(10)end WeaponInHand.Handle.Muzzle.Smoke:Emit(10)if BSpread then BSpread=math.min(WeaponData.MaxSpread*ModTable.MaxSpread,BSpread+WeaponData.AimInaccuracyStepAmount*ModTable.AimInaccuracyStepAmount)RecoilPower=math.min(WeaponData.MaxRecoilPower*ModTable.MaxRecoilPower,RecoilPower+WeaponData.RecoilPowerStepAmount*ModTable.RecoilPowerStepAmount)end generateBullet=generateBullet+1 LastSpreadUpdate=time()if Ammo>0 or not WeaponData.SlideLock then(TS:Create(WeaponInHand.Handle.Slide,TweenInfo.new(30/WeaponData.ShootRate,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,true,0),{C0=WeaponData.SlideEx:inverse()})):Play()elseif Ammo<=0 and WeaponData.SlideLock then(TS:Create(WeaponInHand.Handle.Slide,TweenInfo.new(30/WeaponData.ShootRate,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{C0=WeaponData.SlideEx:inverse()})):Play()end if WeaponData.ShootType<4 then WeaponInHand.Handle.Chamber.Smoke:Emit(10)end for v,s in pairs(WeaponInHand.Handle.Chamber:GetChildren())do if s.Name=="\083\104\101\108\108"then s:Emit(1)end end end function ShellCheck()if WeaponData.ShellEjectionMod and WeaponData.ShootType<4 then if Engine.AmmoModels:FindFirstChild(WeaponData.BulletType)then CreateShell(WeaponData.BulletType,WeaponInHand.Handle.Chamber)else CreateShell("\068\101\102\097\117\108\116",WeaponInHand.Handle.Chamber)end end end function Shoot()if WeaponData and(WeaponData.Type=="\071\117\110"and(not shooting and not reloading))then if reloading or runKeyDown or SafeMode or CheckingMag then mouse1down=false return end if Ammo<=0 or WeaponData.Jammed then WeaponInHand.Handle.Click:Play()mouse1down=false return end mouse1down=true delay(0,function()if WeaponData and WeaponData.ShootType==1 then shooting=true Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)ShellCheck()for v=1,WeaponData.Bullets,1 do Thread:Spawn(CreateBullet)end Ammo=Ammo-1 GunFx()JamChance()UpdateGui()Thread:Spawn(Recoil)wait(60/WeaponData.ShootRate)shooting=false elseif WeaponData and WeaponData.ShootType==2 then for v=1,WeaponData.BurstShot,1 do if shooting or Ammo<=0 or mouse1down==false or WeaponData.Jammed then break end shooting=true Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)ShellCheck()for v=1,WeaponData.Bullets,1 do Thread:Spawn(CreateBullet)end Ammo=Ammo-1 GunFx()JamChance()UpdateGui()Thread:Spawn(Recoil)wait(60/WeaponData.ShootRate)shooting=false end elseif WeaponData and WeaponData.ShootType==3 then while mouse1down do if shooting or Ammo<=0 or WeaponData.Jammed then break end shooting=true Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)ShellCheck()for v=1,WeaponData.Bullets,1 do Thread:Spawn(CreateBullet)end Ammo=Ammo-1 GunFx()JamChance()UpdateGui()Thread:Spawn(Recoil)wait(60/WeaponData.ShootRate)shooting=false end elseif WeaponData and WeaponData.ShootType==4 or WeaponData and WeaponData.ShootType==5 then shooting=true Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)for v=1,WeaponData.Bullets,1 do Thread:Spawn(CreateBullet)end Ammo=Ammo-1 GunFx()UpdateGui()Thread:Spawn(Recoil)PumpAnim()RunCheck()shooting=false end if WeaponData and(WeaponData.Type=="\071\117\110"and WeaponData.IsLauncher)then Evt.RepAmmo:FireServer(WeaponTool,Ammo,StoredAmmo,WeaponData.Jammed)end end)elseif WeaponData and(WeaponData.Type=="\077\101\108\101\101"and not runKeyDown)then if not shooting then shooting=true meleeCast()meleeAttack()RunCheck()shooting=false end end end local j={}local y={}y.cornerPeek=SpringMod.new(0)y.cornerPeek.d=1 y.cornerPeek.s=20 y.peekFactor=math.rad(-15)y.dirPeek=0 function j.Update()y.cornerPeek.t=y.peekFactor*Virar local v=CFrame.fromAxisAngle(Vector3.new(0,0,1),y.cornerPeek.p)cam.CFrame=cam.CFrame*v end;(game:GetService("\082\117\110\083\101\114\118\105\099\101")):BindToRenderStep("\067\097\109\101\114\097 \085\112\100\097\116\101",200,j.Update)function RunCheck()if runKeyDown then mouse1down=false GunStance=3 Evt.GunStance:FireServer(GunStance,AnimData)SprintAnim()else if aimming then GunStance=2 Evt.GunStance:FireServer(GunStance,AnimData)else GunStance=0 Evt.GunStance:FireServer(GunStance,AnimData)end IdleAnim()end end function Stand()Stance:FireServer(Stances,Virar);(TS:Create(char.Humanoid,TweenInfo.new(.3),{CameraOffset=Vector3.new(CameraX,CameraY,char.Humanoid.CameraOffset.Z)})):Play()SE_GUI.MainFrame.Poses.Levantado.Visible=true SE_GUI.MainFrame.Poses.Agaixado.Visible=false SE_GUI.MainFrame.Poses.Deitado.Visible=false char.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,true)IsStanced=false end function Crouch()Stance:FireServer(Stances,Virar);(TS:Create(char.Humanoid,TweenInfo.new(.3),{CameraOffset=Vector3.new(CameraX,CameraY,char.Humanoid.CameraOffset.Z)})):Play()SE_GUI.MainFrame.Poses.Levantado.Visible=false SE_GUI.MainFrame.Poses.Agaixado.Visible=true SE_GUI.MainFrame.Poses.Deitado.Visible=false char.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,false)IsStanced=true end function Prone()Stance:FireServer(Stances,Virar);(TS:Create(char.Humanoid,TweenInfo.new(.3),{CameraOffset=Vector3.new(CameraX,CameraY,char.Humanoid.CameraOffset.Z)})):Play()SE_GUI.MainFrame.Poses.Levantado.Visible=false SE_GUI.MainFrame.Poses.Agaixado.Visible=false SE_GUI.MainFrame.Poses.Deitado.Visible=true char.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,false)IsStanced=true end function Lean()(TS:Create(char.Humanoid,TweenInfo.new(.3),{CameraOffset=Vector3.new(CameraX,CameraY,char.Humanoid.CameraOffset.Z)})):Play()Stance:FireServer(Stances,Virar)if Virar==0 then SE_GUI.MainFrame.Poses.Esg_Left.Visible=false SE_GUI.MainFrame.Poses.Esg_Right.Visible=false elseif Virar==1 then SE_GUI.MainFrame.Poses.Esg_Left.Visible=false SE_GUI.MainFrame.Poses.Esg_Right.Visible=true elseif Virar==-1 then SE_GUI.MainFrame.Poses.Esg_Left.Visible=true SE_GUI.MainFrame.Poses.Esg_Right.Visible=false end end

local Humanoid 	= char:WaitForChild('Humanoid')
local Head 		= char:WaitForChild('Head')
local Torso 	= char:WaitForChild('Torso')
local HumanoidRootPart 	= char:WaitForChild('HumanoidRootPart')
local RootJoint 		= HumanoidRootPart:WaitForChild('RootJoint')
local Neck 				= Torso:WaitForChild('Neck')
local Right_Shoulder 	= Torso:WaitForChild('Right Shoulder')
local Left_Shoulder 	= Torso:WaitForChild('Left Shoulder')
local Right_Hip 		= Torso:WaitForChild('Right Hip')
local Left_Hip 			= Torso:WaitForChild('Left Hip')

local YOffset = Neck.C0.Y
local WaistYOffset = Neck.C0.Y
local CFNew, CFAng = CFrame.new, CFrame.Angles
local Asin = math.asin
local T = 0.15

User.MouseIconEnabled 	= true
plr.CameraMode 			= Enum.CameraMode.Classic

cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = Humanoid

if gameRules.TeamTags then
	local tag = Essential.TeamTag:clone()
	tag.Parent = char
	tag.Disabled = false
end

local ShellFolder = Instance.new("Folder",ACS_Workspace)
ShellFolder.Name = "Casings"
local Limit = gameRules.ShellLimit
local PhysService = game:GetService("PhysicsService")

function CreateShell(Shell,Origin)
	Evt.Shell:FireServer(Shell,Origin.WorldCFrame,WeaponData.EjectionOverride)
end

function SetWalkSpeed(Speed)
	if gameRules.WeaponWeight and WeaponInHand and WeaponData.WeaponWeight then
		if Speed - WeaponData.WeaponWeight < 1 then
			char:WaitForChild("Humanoid").WalkSpeed = 1
		else
			char:WaitForChild("Humanoid").WalkSpeed = Speed - WeaponData.WeaponWeight
		end
	else
		char:WaitForChild("Humanoid").WalkSpeed = Speed
	end
end

Evt.Shell.OnClientEvent:Connect(function(Shell,Origin,Override)
	local Distance = (char.Torso.Position - Origin.Position).Magnitude
	local shellFolder
	if Engine.AmmoModels:FindFirstChild(Shell) then
		shellFolder = Engine.AmmoModels:FindFirstChild(Shell)
	else
		shellFolder = Engine.AmmoModels.Default
	end
	
	local shellStats = require(shellFolder.EjectionForce)
	
	if Distance < 100 then
		local NewShell = shellFolder.Casing:Clone()
		NewShell.Parent = ShellFolder
		NewShell.Anchored = false
		NewShell.CanCollide = true
		NewShell.CFrame = Origin * CFrame.Angles(0,math.rad(0),0)	
		NewShell.Name = Shell.."_Casing"
		NewShell.CastShadow = false
		NewShell.CustomPhysicalProperties = shellStats.PhysProperties

		PhysService:SetPartCollisionGroup(NewShell,"Casings")
		local Att = Instance.new("Attachment",NewShell)
		Att.Position = shellStats.ForcePoint
		local ShellForce = Instance.new("VectorForce",NewShell)
		ShellForce.Visible = false
		
		if Override then
			ShellForce.Force = Override
		else
			ShellForce.Force = shellStats.CalculateForce()
		end
		
		ShellForce.Attachment0 = Att
		Debris:AddItem(ShellForce,0.01)

		if #ShellFolder:GetChildren() > Limit then
			ShellFolder:GetChildren()[math.random(#ShellFolder:GetChildren()/2,#ShellFolder:GetChildren())]:Destroy()
		end

		--NewShell.Touched:Connect(function(partTouched)
		--	if NewShell.AssemblyLinearVelocity.Magnitude > 20 and not partTouched:IsDescendantOf(char) and partTouched.CanCollide then
		--		local NewSound = NewShell.Drop:Clone()
		--		NewSound.Parent = NewShell
		--		NewSound.PlaybackSpeed = math.random(30,50)/40
		--		NewSound:Play()
		--		NewSound.PlayOnRemove = true
		--		NewSound:Destroy()
		--		Debris:AddItem(NewSound,2)
		--	end
		--end)
		
		if gameRules.ShellDespawn > 0 then Debris:AddItem(NewShell,gameRules.ShellDespawn) end
		
		wait(0.25)
		if NewShell and NewShell:FindFirstChild("Drop") then
			local NewSound = NewShell.Drop:Clone()
			NewSound.Parent = NewShell
			NewSound.PlaybackSpeed = math.random(30,50)/40
			NewSound:Play()
			NewSound.PlayOnRemove = true
			NewSound:Destroy()
			Debris:AddItem(NewSound,2)
		end
	end
end)

function handleAction(actionName, inputState, inputObject)

	if PreviousTool and canDrop and actionName == "DropWeapon" and inputState == Enum.UserInputState.Begin and gameRules.WeaponDropping then
		Evt.DropWeapon:FireServer(PreviousTool,require(PreviousTool.ACS_Settings))
		canDrop = false
	end

	if actionName == "Fire" and inputState == Enum.UserInputState.Begin and AnimDebounce then
		Shoot()

		if WeaponData.Type == "Grenade" then
			CookGrenade = true
			Grenade()
		end

	elseif actionName == "Fire" and inputState == Enum.UserInputState.End then
		mouse1down = false
		CookGrenade = false
	end

	if actionName == "Reload" and inputState == Enum.UserInputState.Begin and AnimDebounce and not CheckingMag and not reloading then
		if WeaponData.Jammed then
			Jammed()
		else
			Reload()
		end
	end

	if actionName == "Reload" and inputState == Enum.UserInputState.Begin and reloading and WeaponData.ShellInsert then
		CancelReload = true
	end

	if actionName == "CycleLaser" and inputState == Enum.UserInputState.Begin and LaserAtt then
		SetLaser()
	end

	if actionName == "CycleLight" and inputState == Enum.UserInputState.Begin and TorchAtt then
		SetTorch()
	end

	if actionName == "CycleFiremode" and inputState == Enum.UserInputState.Begin and WeaponData and WeaponData.FireModes.ChangeFiremode then
		Firemode()
	end

	if actionName == "CycleAimpart" and inputState == Enum.UserInputState.Begin then
		SetAimpart()
	end

	if actionName == "ZeroUp" and inputState == Enum.UserInputState.Begin and WeaponData and WeaponData.EnableZeroing  then
		if WeaponData.CurrentZero < WeaponData.MaxZero then
			WeaponInHand.Handle.Click:play()
			WeaponData.CurrentZero = math.min(WeaponData.CurrentZero + WeaponData.ZeroIncrement, WeaponData.MaxZero) 
			UpdateGui()
		end
	end

	if actionName == "ZeroDown" and inputState == Enum.UserInputState.Begin and WeaponData and WeaponData.EnableZeroing  then
		if WeaponData.CurrentZero > 0 then
			WeaponInHand.Handle.Click:play()
			WeaponData.CurrentZero = math.max(WeaponData.CurrentZero - WeaponData.ZeroIncrement, 0) 
			UpdateGui()
		end
	end

	if actionName == "CheckMag" and inputState == Enum.UserInputState.Begin and not CheckingMag and not reloading and not runKeyDown and AnimDebounce and WeaponData.CanCheckMag then
		CheckMagFunction()
	end

	if actionName == "ToggleBipod" and inputState == Enum.UserInputState.Begin and CanBipod then

		BipodActive = not BipodActive
		UpdateGui()
	end

	if actionName == "NVG" and inputState == Enum.UserInputState.Begin and not NVGdebounce then
		if not plr.Character then return; end;
		local helmet = plr.Character:FindFirstChild("Helmet")
		if not helmet then return; end;
		local nvg = helmet:FindFirstChild("Up")
		if not nvg then return; end;
		NVGdebounce = true
		delay(.8,function()
			NVG = not NVG
			Evt.NVG:Fire(NVG)
			NVGdebounce = false		
		end)
	end

	if actionName == "ADS" and inputState == Enum.UserInputState.Begin and AnimDebounce then
		if WeaponData and WeaponData.canAim and GunStance > -2 and not runKeyDown and not CheckingMag then
			aimming = not aimming
			ADS(aimming)
		end

		if WeaponData.Type == "Grenade" then
			GrenadeMode()
		end
	end

	if actionName == "Stand" and inputState == Enum.UserInputState.Begin and ChangeStance and not Swimming and not Sentado and not runKeyDown and not ACS_Client:GetAttribute("Collapsed") then
		if Stances == 2 then
			Crouched = true
			Proned = false
			Stances = 1
			CameraY = -1
			Crouch()


		elseif Stances == 1 then		
			Crouched = false
			Stances = 0
			CameraY = 0
			Stand()
		end	
	end

	if actionName == "Crouch" and inputState == Enum.UserInputState.Begin and ChangeStance and not Swimming and not Sentado and not runKeyDown and not ACS_Client:GetAttribute("Collapsed") then
		if Stances == 0 then
			Stances = 1
			CameraY = -1
			Crouch()
			Crouched = true
		elseif Stances == 1 then	
			Stances = 2
			CameraX = 0
			CameraY = -3.25
			Virar = 0
			Lean()
			Prone()
			Crouched = false
			Proned = true
		end
	end

	if actionName == "ToggleWalk" and inputState == Enum.UserInputState.Begin and ChangeStance and not runKeyDown then
		Steady = not Steady

		SE_GUI.MainFrame.Poses.Steady.Visible = Steady

		if Stances == 0 then
			Stand()
		end
	end

	if actionName == "LeanLeft" and inputState == Enum.UserInputState.Begin and Stances ~= 2 and ChangeStance and not Swimming and not runKeyDown and CanLean and not ACS_Client:GetAttribute("Collapsed") then
		if Virar == 0 or Virar == 1 then
			Virar = -1
			CameraX = -1.25
		else
			Virar = 0
			CameraX = 0
		end
		Lean()
	end

	if actionName == "LeanRight" and inputState == Enum.UserInputState.Begin and Stances ~= 2 and ChangeStance and not Swimming and not runKeyDown and CanLean and not ACS_Client:GetAttribute("Collapsed") then
		if Virar == 0 or Virar == -1 then
			Virar = 1
			CameraX = 1.25
		else
			Virar = 0
			CameraX = 0
		end
		Lean()
	end

	if actionName == "Run" and inputState == Enum.UserInputState.Begin and running and not script.Parent:GetAttribute("Injured") then
		mouse1down = false		
		runKeyDown 	= true
		Stand()
		Stances = 0
		Virar = 0
		CameraX = 0
		CameraY = 0
		Lean()

		--SetWalkSpeed(gameRules.RunWalkSpeed)

		if aimming then
			aimming = false
			ADS(aimming)
		end

		if not CheckingMag and not reloading and WeaponData and WeaponData.Type ~= "Grenade" and (GunStance == 0 or GunStance == 2 or GunStance == 3) then
			GunStance = 3
			Evt.GunStance:FireServer(GunStance,AnimData)
			SprintAnim()
		end

	elseif actionName == "Run" and inputState == Enum.UserInputState.End and runKeyDown then
		runKeyDown 	= false
		Stand()
		if not CheckingMag and not reloading and WeaponData and WeaponData.Type ~= "Grenade" and (GunStance == 0 or GunStance == 2 or GunStance == 3) then
			GunStance = 0
			Evt.GunStance:FireServer(GunStance,AnimData)
			IdleAnim()
		end
	end
end

function resetMods()

	ModTable.camRecoilMod.RecoilUp 		= 1
	ModTable.camRecoilMod.RecoilLeft 	= 1
	ModTable.camRecoilMod.RecoilRight 	= 1
	ModTable.camRecoilMod.RecoilTilt 	= 1

	ModTable.gunRecoilMod.RecoilUp 		= 1
	ModTable.gunRecoilMod.RecoilTilt 	= 1
	ModTable.gunRecoilMod.RecoilLeft 	= 1
	ModTable.gunRecoilMod.RecoilRight 	= 1

	ModTable.AimRM			= 1
	ModTable.SpreadRM 		= 1
	ModTable.DamageMod 		= 1
	ModTable.minDamageMod 	= 1

	ModTable.MinRecoilPower 		= 1
	ModTable.MaxRecoilPower 		= 1
	ModTable.RecoilPowerStepAmount 	= 1

	ModTable.MinSpread 					= 1
	ModTable.MaxSpread 					= 1
	ModTable.AimInaccuracyStepAmount 	= 1
	ModTable.AimInaccuracyDecrease 		= 1
	ModTable.WalkMult 					= 1
	ModTable.MuzzleVelocity 			= 1

end

function setMods(ModData)

	ModTable.camRecoilMod.RecoilUp 		= ModTable.camRecoilMod.RecoilUp * ModData.camRecoil.RecoilUp
	ModTable.camRecoilMod.RecoilLeft 	= ModTable.camRecoilMod.RecoilLeft * ModData.camRecoil.RecoilLeft
	ModTable.camRecoilMod.RecoilRight 	= ModTable.camRecoilMod.RecoilRight * ModData.camRecoil.RecoilRight
	ModTable.camRecoilMod.RecoilTilt 	= ModTable.camRecoilMod.RecoilTilt * ModData.camRecoil.RecoilTilt

	ModTable.gunRecoilMod.RecoilUp 		= ModTable.gunRecoilMod.RecoilUp * ModData.gunRecoil.RecoilUp
	ModTable.gunRecoilMod.RecoilTilt 	= ModTable.gunRecoilMod.RecoilTilt * ModData.gunRecoil.RecoilTilt
	ModTable.gunRecoilMod.RecoilLeft 	= ModTable.gunRecoilMod.RecoilLeft * ModData.gunRecoil.RecoilLeft
	ModTable.gunRecoilMod.RecoilRight 	= ModTable.gunRecoilMod.RecoilRight * ModData.gunRecoil.RecoilRight

	ModTable.AimRM						= ModTable.AimRM * ModData.AimRecoilReduction
	ModTable.SpreadRM 					= ModTable.SpreadRM * ModData.AimSpreadReduction
	ModTable.DamageMod 					= ModTable.DamageMod * ModData.DamageMod
	ModTable.minDamageMod 				= ModTable.minDamageMod * ModData.minDamageMod

	ModTable.MinRecoilPower 			= ModTable.MinRecoilPower * ModData.MinRecoilPower
	ModTable.MaxRecoilPower 			= ModTable.MaxRecoilPower * ModData.MaxRecoilPower
	ModTable.RecoilPowerStepAmount 		= ModTable.RecoilPowerStepAmount * ModData.RecoilPowerStepAmount

	ModTable.MinSpread 					= ModTable.MinSpread * ModData.MinSpread
	ModTable.MaxSpread 					= ModTable.MaxSpread * ModData.MaxSpread
	ModTable.AimInaccuracyStepAmount 	= ModTable.AimInaccuracyStepAmount * ModData.AimInaccuracyStepAmount
	ModTable.AimInaccuracyDecrease 		= ModTable.AimInaccuracyDecrease * ModData.AimInaccuracyDecrease
	ModTable.WalkMult 					= ModTable.WalkMult * ModData.WalkMult
	ModTable.MuzzleVelocity 			= ModTable.MuzzleVelocity * ModData.MuzzleVelocityMod
end

function loadAttachment(weapon)
	if not weapon or not weapon:FindFirstChild("Nodes") then return; end;
	--load sight Att
	if weapon.Nodes:FindFirstChild("Sight") and WeaponData.SightAtt ~= "" then

		SightData =  require(AttModules[WeaponData.SightAtt])

		SightAtt = AttModels[WeaponData.SightAtt]:Clone()
		SightAtt.Parent = weapon
		SightAtt:SetPrimaryPartCFrame(weapon.Nodes.Sight.CFrame)
		weapon.AimPart.CFrame = SightAtt.AimPos.CFrame

		reticle = SightAtt.SightMark.SurfaceGui.Border.Scope	
		if SightData.SightZoom > 0 then
			ModTable.ZoomValue = SightData.SightZoom
		end
		if SightData.SightZoom2 > 0 then
			ModTable.Zoom2Value = SightData.SightZoom2
		end
		setMods(SightData)


		for index, key in pairs(weapon:GetChildren()) do
			if key.Name ~= "IS" then continue; end;
			key.Transparency = 1
		end

		for index, key in pairs(SightAtt:GetChildren()) do
			if not key:IsA('BasePart') then continue; end;
			Ultil.Weld(weapon:WaitForChild("Handle"), key )
			key.Anchored = false
			key.CanCollide = false
		end

	end

	--load Barrel Att
	if weapon.Nodes:FindFirstChild("Barrel") ~= nil and WeaponData.BarrelAtt ~= "" then

		BarrelData =  require(AttModules[WeaponData.BarrelAtt])

		BarrelAtt = AttModels[WeaponData.BarrelAtt]:Clone()
		BarrelAtt.Parent = weapon
		BarrelAtt:SetPrimaryPartCFrame(weapon.Nodes.Barrel.CFrame)


		if BarrelAtt:FindFirstChild("BarrelPos") ~= nil then
			weapon.Handle.Muzzle.WorldCFrame = BarrelAtt.BarrelPos.CFrame
		end

		Suppressor 		= BarrelData.IsSuppressor
		FlashHider 		= BarrelData.IsFlashHider

		setMods(BarrelData)

		for index, key in pairs(BarrelAtt:GetChildren()) do
			if not key:IsA('BasePart') then continue; end;
			Ultil.Weld(weapon:WaitForChild("Handle"), key )
			key.Anchored = false
			key.CanCollide = false
		end
	end

	--load Under Barrel Att
	if weapon.Nodes:FindFirstChild("UnderBarrel") ~= nil and WeaponData.UnderBarrelAtt ~= "" then

		UnderBarrelData =  require(AttModules[WeaponData.UnderBarrelAtt])

		UnderBarrelAtt = AttModels[WeaponData.UnderBarrelAtt]:Clone()
		UnderBarrelAtt.Parent = weapon
		UnderBarrelAtt:SetPrimaryPartCFrame(weapon.Nodes.UnderBarrel.CFrame)


		setMods(UnderBarrelData)
		BipodAtt = UnderBarrelData.IsBipod

		if BipodAtt then
			CAS:BindAction("ToggleBipod", handleAction, true, gameRules.ToggleBipod)
		end

		for index, key in pairs(UnderBarrelAtt:GetChildren()) do
			if not key:IsA('BasePart') then continue; end;
			Ultil.Weld(weapon:WaitForChild("Handle"), key )
			key.Anchored = false
			key.CanCollide = false
		end
	end

	if weapon.Nodes:FindFirstChild("Other") ~= nil and WeaponData.OtherAtt ~= "" then

		OtherData =  require(AttModules[WeaponData.OtherAtt])

		OtherAtt = AttModels[WeaponData.OtherAtt]:Clone()
		OtherAtt.Parent = weapon
		OtherAtt:SetPrimaryPartCFrame(weapon.Nodes.Other.CFrame)


		setMods(OtherData)
		LaserAtt = OtherData.EnableLaser
		TorchAtt = OtherData.EnableFlashlight

		if OtherData.InfraRed then
			IREnable = true
		end

		for index, key in pairs(OtherAtt:GetChildren()) do
			if not key:IsA('BasePart') then continue; end;
			Ultil.Weld(weapon:WaitForChild("Handle"), key )
			key.Anchored = false
			key.CanCollide = false
		end
	end
end

function SetLaser()
	if gameRules.RealisticLaser and IREnable then
		if not LaserActive and not IRmode then
			LaserActive = true
			IRmode 		= true

		elseif LaserActive and IRmode then
			IRmode 		= false
		else
			LaserActive = false
			IRmode 		= false
		end
	else
		LaserActive = not LaserActive
	end

	WeaponInHand.Handle.Click:play()
	UpdateGui()

	if LaserActive then
		if Pointer then return; end;
		for index, Key in pairs(WeaponInHand:GetDescendants()) do
			if not Key:IsA("BasePart") or Key.Name ~= "LaserPoint" then continue; end;
			local LaserPointer = Instance.new('Part',Key)
			LaserPointer.Shape = 'Ball'
			LaserPointer.Size = Vector3.new(0.2, 0.2, 0.2)
			LaserPointer.CanCollide = false
			LaserPointer.Color = Key.Color
			LaserPointer.Material = Enum.Material.Neon

			local LaserSP = Instance.new('Attachment',Key)			
			local LaserEP = Instance.new('Attachment',LaserPointer)

			local Laser = Instance.new('Beam',LaserPointer)
			Laser.Transparency = NumberSequence.new(0)
			Laser.LightEmission = 1
			Laser.LightInfluence = 1
			Laser.Attachment0 = LaserSP
			Laser.Attachment1 = LaserEP
			Laser.Color = ColorSequence.new(Key.Color)
			Laser.FaceCamera = true
			Laser.Width0 = 0.01
			Laser.Width1 = 0.01

			if gameRules.RealisticLaser then
				Laser.Enabled = false
			end

			Pointer = LaserPointer
			break
		end
	else
		for index, Key in pairs(WeaponInHand:GetDescendants()) do
			if not Key:IsA("BasePart") or Key.Name ~= "LaserPoint" then continue; end;
			Key:ClearAllChildren()
			break
		end
		Pointer = nil
		if gameRules.ReplicatedLaser then
			Evt.SVLaser:FireServer(nil,2,nil,false,WeaponTool)
		end
	end
end

function SetTorch()

	TorchActive = not TorchActive

	for index, Key in pairs(WeaponInHand:GetDescendants()) do
		if not Key:IsA("BasePart") or Key.Name ~= "FlashPoint" then continue; end;
		Key.Light.Enabled = TorchActive
	end

	Evt.SVFlash:FireServer(WeaponTool,TorchActive)
	WeaponInHand.Handle.Click:play()
	UpdateGui()
end

function ToggleADS(Type)
	local ADSTween
	if WeaponData.adsTime then
		ADSTween = TweenInfo.new(WeaponData.adsTime / 20,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,WeaponData.adsTime / 20)
	else
		ADSTween = TweenInfo.new(0.2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0.2)
	end
	if Type == "REG" then
		for _, child in pairs(WeaponInHand:GetChildren()) do
			if child.Name == "REG" then
				TS:Create(child, ADSTween, {Transparency = 0}):Play()
			elseif child.Name == "ADS" then
				TS:Create(child, ADSTween, {Transparency = 1}):Play()
			end
		end
	elseif Type == "ADS" then
		for _, child in pairs(WeaponInHand:GetChildren()) do
			if child.Name == "REG" then
				TS:Create(child, ADSTween, {Transparency = 1}):Play()
			elseif child.Name == "ADS" then
				TS:Create(child, ADSTween, {Transparency = 0}):Play()
			end
		end
	end
end

function ADS(aimming)
	if not WeaponData or not WeaponInHand then return; end;
	if aimming then

		if SafeMode then
			SafeMode = false
			GunStance = 0
			IdleAnim()
			UpdateGui()
		end

		game:GetService('UserInputService').MouseDeltaSensitivity = (Sens/100)

		WeaponInHand.Handle.AimDown:Play()
		
		if WeaponData.ADSEnabled then
			if WeaponData.ADSEnabled[AimPartMode] then
				ToggleADS("ADS")
			end
		else
			ToggleADS("ADS")
		end

		GunStance = 2
		Evt.GunStance:FireServer(GunStance,AnimData)

		TS:Create(Crosshair.Up, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
		TS:Create(Crosshair.Down, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
		TS:Create(Crosshair.Left, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
		TS:Create(Crosshair.Right, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
		TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 1}):Play()

	else
		game:GetService('UserInputService').MouseDeltaSensitivity = 1
		WeaponInHand.Handle.AimUp:Play()
		
		ToggleADS("REG")

		GunStance = 0
		Evt.GunStance:FireServer(GunStance,AnimData)

		if  WeaponData.CrossHair then
			TS:Create(Crosshair.Up, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
			TS:Create(Crosshair.Down, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
			TS:Create(Crosshair.Left, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
			TS:Create(Crosshair.Right, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
		end

		if  WeaponData.CenterDot then
			TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 0}):Play()
		else
			TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 1}):Play()
		end
	end
end

function SetAimpart()
	if aimming then
		if AimPartMode == 1 then
			AimPartMode = 2
			if WeaponInHand:FindFirstChild('AimPart2') then
				CurAimpart = WeaponInHand:FindFirstChild('AimPart2')
			end 
		else
			AimPartMode = 1
			CurAimpart = WeaponInHand:FindFirstChild('AimPart')
		end
		--print("Set to Aimpart: "..AimPartMode)
		if WeaponData.ADSEnabled then
			if WeaponData.ADSEnabled[AimPartMode] then
				ToggleADS("ADS")
			else
				ToggleADS("REG")
			end
		end
	end
end

function Firemode()

	WeaponInHand.Handle.SafetyClick:Play()
	mouse1down = false

	---Semi Settings---		
	if WeaponData.ShootType == 1 and WeaponData.FireModes.Burst == true then
		WeaponData.ShootType = 2
	elseif WeaponData.ShootType == 1 and WeaponData.FireModes.Burst == false and WeaponData.FireModes.Auto == true then
		WeaponData.ShootType = 3
		---Burst Settings---
	elseif WeaponData.ShootType == 2 and WeaponData.FireModes.Auto == true then
		WeaponData.ShootType = 3
	elseif WeaponData.ShootType == 2 and WeaponData.FireModes.Semi == true and WeaponData.FireModes.Auto == false then
		WeaponData.ShootType = 1
		---Auto Settings---
	elseif WeaponData.ShootType == 3 and WeaponData.FireModes.Semi == true then
		WeaponData.ShootType = 1
	elseif WeaponData.ShootType == 3 and WeaponData.FireModes.Semi == false and WeaponData.FireModes.Burst == true then
		WeaponData.ShootType = 2
		---Explosive Settings---
	end
	UpdateGui()

end

function setup(Tool)

	if not char or not Tool or not char:FindFirstChild("Humanoid") or char.Humanoid.Health <= 0 then return; end;

	local ToolCheck 		= Tool
	local GunModelCheck 	= GunModels:FindFirstChild(Tool.Name)

	if not ToolCheck or not GunModelCheck then warn("Tool Or Gun Model Doesn't Exist") return; end;

	ToolEquip = true
	User.MouseIconEnabled 	= false
	plr.CameraMode 			= Enum.CameraMode.LockFirstPerson

	WeaponTool 		= ToolCheck
	if WeaponTool then
		PreviousTool = WeaponTool
		canDrop = true
	end

	WeaponData 		= require(Tool:FindFirstChild("ACS_Settings"))
	AnimData 		= require(Tool:FindFirstChild("ACS_Animations"))
	WeaponInHand 	= GunModelCheck:Clone()
	WeaponInHand.PrimaryPart = WeaponInHand:WaitForChild("Handle")
	
	if WeaponData.Type == "Gun" then WeaponInHand.Handle.AimDown:Play() end
	
	Evt.Equip:FireServer(Tool,1,WeaponData,AnimData)
	
	RepValues = Tool:WaitForChild("RepValues")

	ViewModel = ArmModel:WaitForChild("Arms"):Clone()
	ViewModel.Name = "Viewmodel"

	if char:WaitForChild("Body Colors") then
		local Colors = char:WaitForChild("Body Colors"):Clone()
		Colors.Parent = ViewModel
	end

	if char:FindFirstChild("Shirt") then
		local Shirt = char:FindFirstChild("Shirt"):Clone()
		Shirt.Parent = ViewModel
	end

	AnimPart = Instance.new("Part",ViewModel)
	AnimPart.Size = Vector3.new(0.1,0.1,0.1)
	AnimPart.Anchored = true
	AnimPart.CanCollide = false
	AnimPart.Transparency = 1

	ViewModel.PrimaryPart = AnimPart

	LArmWeld = Instance.new("Motor6D",AnimPart)
	LArmWeld.Name = "LeftArm"
	LArmWeld.Part0 = AnimPart

	RArmWeld = Instance.new("Motor6D",AnimPart)
	RArmWeld.Name = "RightArm"
	RArmWeld.Part0 = AnimPart

	GunWeld = Instance.new("Motor6D",AnimPart)
	GunWeld.Name = "Handle"

	--setup arms to camera

	ViewModel.Parent = cam

	maincf = AnimData.MainCFrame
	guncf = AnimData.GunCFrame

	larmcf = AnimData.LArmCFrame
	rarmcf = AnimData.RArmCFrame


	if  WeaponData.CrossHair then
		TS:Create(Crosshair.Up, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
		TS:Create(Crosshair.Down, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
		TS:Create(Crosshair.Left, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
		TS:Create(Crosshair.Right, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()	

		if WeaponData.Bullets > 1 then
			Crosshair.Up.Rotation = 90
			Crosshair.Down.Rotation = 90
			Crosshair.Left.Rotation = 90
			Crosshair.Right.Rotation = 90
		else
			Crosshair.Up.Rotation = 0
			Crosshair.Down.Rotation = 0
			Crosshair.Left.Rotation = 0
			Crosshair.Right.Rotation = 0
		end

	else
		TS:Create(Crosshair.Up, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
		TS:Create(Crosshair.Down, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
		TS:Create(Crosshair.Left, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
		TS:Create(Crosshair.Right, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
	end

	if  WeaponData.CenterDot then
		TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 0}):Play()
	else
		TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 1}):Play()
	end

	LArm = ViewModel:WaitForChild("Left Arm")
	LArmWeld.Part1 = LArm
	LArmWeld.C0 = CFrame.new()
	LArmWeld.C1 = CFrame.new(1,-1,-5) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0)):inverse()

	RArm = ViewModel:WaitForChild("Right Arm")
	RArmWeld.Part1 = RArm
	RArmWeld.C0 = CFrame.new()
	RArmWeld.C1 = CFrame.new(-1,-1,-5) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0)):inverse()
	GunWeld.Part0 = RArm

	LArm.Anchored = false
	RArm.Anchored = false

	--setup weapon to camera
	ModTable.ZoomValue 		= WeaponData.Zoom
	ModTable.Zoom2Value 	= WeaponData.Zoom2
	IREnable 				= WeaponData.InfraRed


	CAS:BindAction("Fire", handleAction, true, Enum.UserInputType.MouseButton1, Enum.KeyCode.ButtonR2)
	CAS:BindAction("ADS", handleAction, true, Enum.UserInputType.MouseButton2, Enum.KeyCode.ButtonL2) 
	CAS:BindAction("Reload", handleAction, true, gameRules.Reload, Enum.KeyCode.ButtonB)
	CAS:BindAction("CycleAimpart", handleAction, false, gameRules.SwitchSights)

	CAS:BindAction("CycleLaser", handleAction, true, gameRules.ToggleLaser)
	CAS:BindAction("CycleLight", handleAction, true, gameRules.ToggleLight)

	CAS:BindAction("CycleFiremode", handleAction, false, gameRules.FireMode)
	CAS:BindAction("CheckMag", handleAction, false, gameRules.CheckMag)

	CAS:BindAction("ZeroDown", handleAction, false, gameRules.ZeroDown)
	CAS:BindAction("ZeroUp", handleAction, false, gameRules.ZeroUp)

	CAS:BindAction("DropWeapon", handleAction, true, gameRules.DropGun)

	loadAttachment(WeaponInHand)

	BSpread				= math.min(WeaponData.MinSpread * ModTable.MinSpread, WeaponData.MaxSpread * ModTable.MaxSpread)
	RecoilPower 		= math.min(WeaponData.MinRecoilPower * ModTable.MinRecoilPower, WeaponData.MaxRecoilPower * ModTable.MaxRecoilPower)

	Ammo = RepValues.Mag.Value
	StoredAmmo = RepValues.StoredAmmo.Value
	CurAimpart = WeaponInHand:FindFirstChild("AimPart")
	
	for _, cPart in pairs(WeaponInHand:GetChildren()) do
		if cPart.Name == "Warhead" and Ammo < 1 then
			cPart.Transparency = 1
		end
	end

	for index, Key in pairs(WeaponInHand:GetDescendants()) do
		if Key:IsA("BasePart") and Key.Name == "FlashPoint" then
			TorchAtt = true
		end
		if Key:IsA("BasePart") and Key.Name == "LaserPoint" then
			LaserAtt = true
		end
	end
	
	if WeaponData.Type == "Gun" and WeaponData.ShellEjectionMod then
		WeaponInHand.Bolt.SlidePull.Played:Connect(function()
			--print(canPump)
			if Ammo > 0 or canPump then
				CreateShell(WeaponData.BulletType,WeaponInHand.Handle.Chamber)
				WeaponInHand.Handle.Chamber.Smoke:Emit(10)
				canPump = false
			end
		end)
	end

	if WeaponData.EnableHUD then
		SE_GUI.GunHUD.Visible = true
	end
	UpdateGui()

	for index, key in pairs(WeaponInHand:GetChildren()) do
		if key:IsA('BasePart') and key.Name ~= 'Handle' then

			if key.Name ~= "Bolt" and key.Name ~= 'Lid' and key.Name ~= "Slide" then
				Ultil.Weld(WeaponInHand:WaitForChild("Handle"), key)
			end

			if key.Name == "Bolt" or key.Name == "Slide" then
				Ultil.WeldComplex(WeaponInHand:WaitForChild("Handle"), key, key.Name)
			end;

			if key.Name == "Lid" then
				if WeaponInHand:FindFirstChild('LidHinge') then
					Ultil.Weld(key, WeaponInHand:WaitForChild("LidHinge"))
				else
					Ultil.Weld(key, WeaponInHand:WaitForChild("Handle"))
				end
			end
		end
	end;

	for L_213_forvar1, L_214_forvar2 in pairs(WeaponInHand:GetChildren()) do
		if L_214_forvar2:IsA('BasePart') then
			L_214_forvar2.Anchored = false
			L_214_forvar2.CanCollide = false
		end
	end;

	if WeaponInHand:FindFirstChild("Nodes") then
		for L_213_forvar1, L_214_forvar2 in pairs(WeaponInHand.Nodes:GetChildren()) do
			if L_214_forvar2:IsA('BasePart') then
				Ultil.Weld(WeaponInHand:WaitForChild("Handle"), L_214_forvar2)
				L_214_forvar2.Anchored = false
				L_214_forvar2.CanCollide = false
			end
		end;
	end

	GunWeld.Part1 = WeaponInHand:WaitForChild("Handle")
	GunWeld.C1 = guncf

	--WeaponInHand:SetPrimaryPartCFrame( RArm.CFrame * guncf)

	WeaponInHand.Parent = ViewModel	
	if Ammo <= 0 and WeaponData.Type == "Gun" then
		WeaponInHand.Handle.Slide.C0 = WeaponData.SlideEx:inverse()
	end
	EquipAnim()
	if WeaponData and WeaponData.Type ~= "Grenade" then
		RunCheck()
	end

end

function unset()
	ToolEquip = false
	Evt.Equip:FireServer(WeaponTool,2)
	--unsetup weapon data module
	CAS:UnbindAction("Fire")
	CAS:UnbindAction("ADS")
	CAS:UnbindAction("Reload")
	CAS:UnbindAction("CycleLaser")
	CAS:UnbindAction("CycleLight")
	CAS:UnbindAction("CycleFiremode")
	CAS:UnbindAction("CycleAimpart")
	CAS:UnbindAction("ZeroUp")
	CAS:UnbindAction("ZeroDown")
	CAS:UnbindAction("CheckMag")

	mouse1down = false
	aimming = false

	TS:Create(cam,AimTween,{FieldOfView = 70}):Play()
	TS:Create(Crosshair.Up, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
	TS:Create(Crosshair.Down, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
	TS:Create(Crosshair.Left, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
	TS:Create(Crosshair.Right, TweenInfo.new(.2,Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
	TS:Create(Crosshair.Center, TweenInfo.new(.2,Enum.EasingStyle.Linear), {ImageTransparency = 1}):Play()

	User.MouseIconEnabled = true
	game:GetService('UserInputService').MouseDeltaSensitivity = 1
	cam.CameraType = Enum.CameraType.Custom
	plr.CameraMode = Enum.CameraMode.Classic

	if WeaponInHand then
		
		if WeaponData.Type == "Gun" then
			local chambered = true
			if WeaponData.Jammed or Ammo < 1 then chambered = false end
			Evt.RepAmmo:FireServer(WeaponTool,Ammo,StoredAmmo,WeaponData.Jammed)
			--WeaponData.AmmoInGun = Ammo
			--WeaponData.StoredAmmo = StoredAmmo
		end

		ViewModel:Destroy()
		ViewModel 		= nil
		WeaponInHand	= nil
		WeaponTool		= nil
		LArm 			= nil
		RArm 			= nil
		LArmWeld 		= nil
		RArmWeld 		= nil
		WeaponData 		= nil
		AnimData		= nil
		SightAtt		= nil
		reticle			= nil
		BarrelAtt 		= nil
		UnderBarrelAtt 	= nil
		OtherAtt 		= nil
		LaserAtt 		= false
		LaserActive		= false
		IRmode			= false
		TorchAtt 		= false
		TorchActive 	= false
		BipodAtt 		= false
		BipodActive 	= false
		LaserDist 		= 0
		Pointer 		= nil
		BSpread 		= nil
		RecoilPower 	= nil
		Suppressor 		= false
		FlashHider 		= false
		CancelReload 	= false
		reloading 		= false
		SafeMode		= false
		CheckingMag		= false
		GRDebounce 		= false
		CookGrenade 	= false
		GunStance 		= 0
		resetMods()
		generateBullet 	= 1
		AimPartMode 	= 1

		SE_GUI.GunHUD.Visible = false
		SE_GUI.GrenadeForce.Visible = false
		BipodCF = CFrame.new()
		if gameRules.ReplicatedLaser then
			Evt.SVLaser:FireServer(nil,2,nil,false,WeaponTool)
		end
	end

	--if runKeyDown then
	--	SetWalkSpeed(gameRules.RunWalkSpeed)
	--elseif Crouched then
	--	SetWalkSpeed(gameRules.CrouchWalkSpeed)
	--elseif Proned then
	--	SetWalkSpeed(gameRules.ProneWalkSpeed)
	--elseif Steady then
	--	SetWalkSpeed(gameRules.SlowPaceWalkSpeed)
	--else
	--	SetWalkSpeed(gameRules.NormalWalkSpeed)
	--end
end

local HalfStep = false
function HeadMovement()
	if gameRules.HeadMovement or WeaponInHand then
		if not char:FindFirstChild("HumanoidRootPart") or not char:FindFirstChild("Humanoid") or char.Humanoid.Health <= 0 then return; end;
		if char.Humanoid.RigType == Enum.HumanoidRigType.R15 then return; end;
		if not ACS_Client or ACS_Client:GetAttribute("Collapsed") then return; end;
		local CameraDirection = char.HumanoidRootPart.CFrame:toObjectSpace(cam.CFrame).lookVector
		if Neck then
			HalfStep = not HalfStep
			local neckCFrame = CFNew(0, -.5, 0) * CFAng(0, Asin(CameraDirection.x)/1.15, 0) * CFAng(-Asin(cam.CFrame.LookVector.y)+Asin(char.Torso.CFrame.lookVector.Y), 0, 0) * CFAng(-math.rad(90), 0, math.rad(180))
			TS:Create(Neck, TweenInfo.new(.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {C1 = neckCFrame}):Play()
			if not HalfStep then return; end;
			Evt.HeadRot:FireServer(neckCFrame)
		end
	elseif not gameRules.HeadMovement then
		local neckCFrame = CFrame.new(0,-0.5,0) * CFrame.Angles(math.rad(90),math.rad(180),0)
		TS:Create(Neck, TweenInfo.new(.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {C1 = neckCFrame}):Play()
		Evt.HeadRot:FireServer(neckCFrame)
	end
end

function renderCam()			
	cam.CFrame = cam.CFrame*CFrame.Angles(cameraspring.p.x,cameraspring.p.y,cameraspring.p.z)
end

function renderGunRecoil()			
	recoilcf = recoilcf*CFrame.Angles(RecoilSpring.p.x,RecoilSpring.p.y,RecoilSpring.p.z)
end

function Recoil()
	local vr = (math.random(WeaponData.camRecoil.camRecoilUp[1], WeaponData.camRecoil.camRecoilUp[2])/2) * ModTable.camRecoilMod.RecoilUp
	local lr = (math.random(WeaponData.camRecoil.camRecoilLeft[1], WeaponData.camRecoil.camRecoilLeft[2])) * ModTable.camRecoilMod.RecoilLeft
	local rr = (math.random(WeaponData.camRecoil.camRecoilRight[1], WeaponData.camRecoil.camRecoilRight[2])) * ModTable.camRecoilMod.RecoilRight
	local hr = (math.random(-rr, lr)/2)
	local tr = (math.random(WeaponData.camRecoil.camRecoilTilt[1], WeaponData.camRecoil.camRecoilTilt[2])/2) * ModTable.camRecoilMod.RecoilTilt

	local RecoilX = math.rad(vr * RAND( 1, 1, .1))
	local RecoilY = math.rad(hr * RAND(-1, 1, .1))
	local RecoilZ = math.rad(tr * RAND(-1, 1, .1))

	local gvr = (math.random(WeaponData.gunRecoil.gunRecoilUp[1], WeaponData.gunRecoil.gunRecoilUp[2]) /10) * ModTable.gunRecoilMod.RecoilUp
	local gdr = (math.random(-1,1) * math.random(WeaponData.gunRecoil.gunRecoilTilt[1], WeaponData.gunRecoil.gunRecoilTilt[2]) /10) * ModTable.gunRecoilMod.RecoilTilt
	local glr = (math.random(WeaponData.gunRecoil.gunRecoilLeft[1], WeaponData.gunRecoil.gunRecoilLeft[2])) * ModTable.gunRecoilMod.RecoilLeft
	local grr = (math.random(WeaponData.gunRecoil.gunRecoilRight[1], WeaponData.gunRecoil.gunRecoilRight[2])) * ModTable.gunRecoilMod.RecoilRight

	local ghr = (math.random(-grr, glr)/10)	

	local ARR = WeaponData.AimRecoilReduction * ModTable.AimRM

	if BipodActive then
		cameraspring:accelerate(Vector3.new( RecoilX, RecoilY/2, 0 ))

		if not aimming then
			RecoilSpring:accelerate(Vector3.new( math.rad(.25 * gvr * RecoilPower), math.rad(.25 * ghr * RecoilPower), math.rad(.25 * gdr)))
			recoilcf = recoilcf * CFrame.new(0,0,.1) * CFrame.Angles( math.rad(.25 * gvr * RecoilPower ),math.rad(.25 * ghr * RecoilPower ),math.rad(.25 * gdr * RecoilPower ))

		else
			RecoilSpring:accelerate(Vector3.new( math.rad( .25 * gvr * RecoilPower/ARR) , math.rad(.25 * ghr * RecoilPower/ARR), math.rad(.25 * gdr/ ARR)))
			recoilcf = recoilcf * CFrame.new(0,0,.1) * CFrame.Angles( math.rad(.25 * gvr * RecoilPower/ARR ),math.rad(.25 * ghr * RecoilPower/ARR ),math.rad(.25 * gdr * RecoilPower/ARR ))
		end

		Thread:Wait(0.05)
		cameraspring:accelerate(Vector3.new(-RecoilX, -RecoilY/2, 0))

	else
		cameraspring:accelerate(Vector3.new( RecoilX , RecoilY, RecoilZ ))
		if not aimming then
			RecoilSpring:accelerate(Vector3.new( math.rad(gvr * RecoilPower), math.rad(ghr * RecoilPower), math.rad(gdr)))
			recoilcf = recoilcf * CFrame.new(0,-0.05,.1) * CFrame.Angles( math.rad( gvr * RecoilPower ),math.rad( ghr * RecoilPower ),math.rad( gdr * RecoilPower ))

		else
			RecoilSpring:accelerate(Vector3.new( math.rad(gvr * RecoilPower/ARR) , math.rad(ghr * RecoilPower/ARR), math.rad(gdr/ ARR)))
			recoilcf = recoilcf * CFrame.new(0,0,.1) * CFrame.Angles( math.rad( gvr * RecoilPower/ARR ),math.rad( ghr * RecoilPower/ARR ),math.rad( gdr * RecoilPower/ARR ))
		end
	end
end

function CheckForHumanoid(L_225_arg1)
	local L_226_ = false
	local L_227_ = nil
	if L_225_arg1 then
		if (L_225_arg1.Parent:FindFirstChildOfClass("Humanoid") or L_225_arg1.Parent.Parent:FindFirstChildOfClass("Humanoid")) then
			L_226_ = true
			if L_225_arg1.Parent:FindFirstChildOfClass('Humanoid') then
				L_227_ = L_225_arg1.Parent:FindFirstChildOfClass('Humanoid')
			elseif L_225_arg1.Parent.Parent:FindFirstChildOfClass('Humanoid') then
				L_227_ = L_225_arg1.Parent.Parent:FindFirstChildOfClass('Humanoid')
			end
		else
			L_226_ = false
		end	
	end
	return L_226_, L_227_
end

function CastRay(Bullet, Origin)
	if not Bullet then return; end;

	local Bpos = Bullet.Position
	local Bpos2 = cam.CFrame.Position

	local recast = false
	local TotalDistTraveled = 0
	local Debounce = false
	local raycastResult

	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = Ignore_Model
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	raycastParams.IgnoreWater = true

	while Bullet do
		Run.Heartbeat:Wait()
		if not Bullet.Parent then break; end;

		Bpos = Bullet.Position
		TotalDistTraveled = (Bullet.Position - Origin).Magnitude

		if TotalDistTraveled > 7000 then
			Bullet:Destroy()
			Debounce = true
			break
		end

		for _, plyr in pairs(game.Players:GetPlayers()) do
			if Debounce or plyr == plr or not plyr.Character or not plyr.Character:FindFirstChild('Head') or (plyr.Character.Head.Position - Bpos).magnitude > 25 then continue; end;
			Evt.Whizz:FireServer(plyr)
			Evt.Suppression:FireServer(plyr,1,nil,nil)
			Debounce = true
		end

		-- Set an origin and directional vector
		raycastResult = workspace:Raycast(Bpos2, (Bpos - Bpos2) * 1, raycastParams)

		recast = false

		if raycastResult then
			local Hit2 = raycastResult.Instance

			if Hit2 and Hit2.Parent:IsA('Accessory') or Hit2.Parent:IsA('Hat') then
				for _,players in pairs(game.Players:GetPlayers()) do
					if players.Character then
						for i, hats in pairs(players.Character:GetChildren()) do
							if hats:IsA("Accessory") then
								table.insert(Ignore_Model, hats)
							end
						end
					end
				end
				recast = true
				CastRay(Bullet, Origin)
				break
			end

			if Hit2 and Hit2.Name == "Ignorable" or Hit2.Name == "Ignore" or Hit2.Parent.Name == "Top" or Hit2.Parent.Name == "Helmet" or Hit2.Parent.Name == "Up" or Hit2.Parent.Name == "Down" or Hit2.Parent.Name == "Face" or Hit2.Parent.Name == "Olho" or Hit2.Parent.Name == "Headset" or Hit2.Parent.Name == "Numero" or Hit2.Parent.Name == "Vest" or Hit2.Parent.Name == "Chest" or Hit2.Parent.Name == "Waist" or Hit2.Parent.Name == "Back" or Hit2.Parent.Name == "Belt" or Hit2.Parent.Name == "Leg1" or Hit2.Parent.Name == "Leg2" or Hit2.Parent.Name == "Arm1"  or Hit2.Parent.Name == "Arm2" then
				table.insert(Ignore_Model, Hit2)
				recast = true
				CastRay(Bullet, Origin)
				break
			end

			if Hit2 and Hit2.Parent.Name == "Top" or Hit2.Parent.Name == "Helmet" or Hit2.Parent.Name == "Up" or Hit2.Parent.Name == "Down" or Hit2.Parent.Name == "Face" or Hit2.Parent.Name == "Olho" or Hit2.Parent.Name == "Headset" or Hit2.Parent.Name == "Numero" or Hit2.Parent.Name == "Vest" or Hit2.Parent.Name == "Chest" or Hit2.Parent.Name == "Waist" or Hit2.Parent.Name == "Back" or Hit2.Parent.Name == "Belt" or Hit2.Parent.Name == "Leg1" or Hit2.Parent.Name == "Leg2" or Hit2.Parent.Name == "Arm1"  or Hit2.Parent.Name == "Arm2" then
				table.insert(Ignore_Model, Hit2.Parent)
				recast = true
				CastRay(Bullet, Origin)
				break
			end

			if Hit2 and (Hit2.Transparency >= 1 or Hit2.CanCollide == false) and Hit2.Name ~= 'Head' and Hit2.Name ~= 'Right Arm' and Hit2.Name ~= 'Left Arm' and Hit2.Name ~= 'Right Leg' and Hit2.Name ~= 'Left Leg' and Hit2.Name ~= "UpperTorso" and Hit2.Name ~= "LowerTorso" and Hit2.Name ~= "RightUpperArm" and Hit2.Name ~= "RightLowerArm" and Hit2.Name ~= "RightHand" and Hit2.Name ~= "LeftUpperArm" and Hit2.Name ~= "LeftLowerArm" and Hit2.Name ~= "LeftHand" and Hit2.Name ~= "RightUpperLeg" and Hit2.Name ~= "RightLowerLeg" and Hit2.Name ~= "RightFoot" and Hit2.Name ~= "LeftUpperLeg" and Hit2.Name ~= "LeftLowerLeg" and Hit2.Name ~= "LeftFoot" and Hit2.Name ~= 'Armor' and Hit2.Name ~= 'EShield' then
				table.insert(Ignore_Model, Hit2)
				recast = true
				CastRay(Bullet, Origin)
				break
			end

			if not recast then

				Bullet:Destroy()
				Debounce = true

				local FoundHuman,VitimaHuman = CheckForHumanoid(raycastResult.Instance)
				HitMod.HitEffect(Ignore_Model, raycastResult.Position, raycastResult.Instance , raycastResult.Normal, raycastResult.Material, WeaponData)
				Evt.HitEffect:FireServer(raycastResult.Position, raycastResult.Instance , raycastResult.Normal, raycastResult.Material, WeaponData)

				local HitPart = raycastResult.Instance
				TotalDistTraveled = (raycastResult.Position - Origin).Magnitude

				if FoundHuman == true and VitimaHuman.Health > 0 and WeaponData then
					local SKP_02 = SKP_01.."-"..plr.UserId

					if HitPart.Name == "Head" or HitPart.Parent.Name == "Top" or HitPart.Parent.Name == "Headset" or HitPart.Parent.Name == "Olho" or HitPart.Parent.Name == "Face" or HitPart.Parent.Name == "Numero" then
						Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, TotalDistTraveled, 1, WeaponData, ModTable, nil, nil, SKP_02)
					elseif HitPart.Name == "Torso" or HitPart.Name == "UpperTorso" or HitPart.Name == "LowerTorso" or HitPart.Parent.Name == "Chest" or HitPart.Parent.Name == "Waist" or HitPart.Name == "Right Arm" or HitPart.Name == "Left Arm" or HitPart.Name == "RightUpperArm" or HitPart.Name == "RightLowerArm" or HitPart.Name == "RightHand" or HitPart.Name == "LeftUpperArm" or HitPart.Name == "LeftLowerArm" or HitPart.Name == "LeftHand" then				
						Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, TotalDistTraveled, 2, WeaponData, ModTable, nil, nil, SKP_02)
					elseif HitPart.Name == "Right Leg" or HitPart.Name == "Left Leg" or HitPart.Name == "RightUpperLeg" or HitPart.Name == "RightLowerLeg" or HitPart.Name == "RightFoot" or HitPart.Name == "LeftUpperLeg" or HitPart.Name == "LeftLowerLeg" or HitPart.Name == "LeftFoot" then
						Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, TotalDistTraveled, 3, WeaponData, ModTable, nil, nil, SKP_02)		
					end	
				end
			end
			break
		end

		Bpos2 = Bpos
	end
end

local Tracers = 0
function TracerCalculation()
	if not WeaponData.Tracer and not WeaponData.BulletFlare then return false; end;

	if WeaponData.RandomTracer.Enabled then
		if math.random(1, 100) <= WeaponData.RandomTracer.Chance then return true; end;
		return false;
	end;

	if Tracers >= WeaponData.TracerEveryXShots then
		Tracers = 0;
		return true;
	end;
	Tracers = Tracers + 1;
	return false;
end;

function CreateBullet()
	
	if WeaponData.IsLauncher then
		for _, cPart in pairs(WeaponInHand:GetChildren()) do
			if cPart.Name == "Warhead" then
				cPart.Transparency = 1
			end
		end
	end

	local Bullet = Instance.new("Part",ACS_Workspace.Client)
	Bullet.Name = plr.Name.."_Bullet"
	Bullet.CanCollide = false
	Bullet.Shape = Enum.PartType.Ball
	Bullet.Transparency = 1
	Bullet.Size = Vector3.new(1,1,1)

	local Origin 		= WeaponInHand.Handle.Muzzle.WorldPosition
	local Direction 	= WeaponInHand.Handle.Muzzle.WorldCFrame.LookVector + (WeaponInHand.Handle.Muzzle.WorldCFrame.UpVector * (((WeaponData.BulletDrop * WeaponData.CurrentZero/4)/WeaponData.MuzzleVelocity))/2)
	local BulletCF 		= CFrame.new(Origin, Direction) 
	local WalkMul 		= WeaponData.WalkMult * ModTable.WalkMult
	local BColor 		= Color3.fromRGB(255,255,255)
	local balaspread

	if aimming and WeaponData.Bullets <= 1 then
		balaspread = CFrame.Angles(
			math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / (10 * WeaponData.AimSpreadReduction)),
			math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / (10 * WeaponData.AimSpreadReduction)),
			math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / (10 * WeaponData.AimSpreadReduction))
		)
	else
		balaspread = CFrame.Angles(
			math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / 10),
			math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / 10),
			math.rad(RAND(-BSpread - (charspeed/1) * WalkMul, BSpread + (charspeed/1) * WalkMul) / 10)
		)
	end

	Direction = balaspread * Direction

	local Visivel = TracerCalculation()

	if WeaponData.RainbowMode then
		BColor = Color3.fromRGB(math.random(0,255),math.random(0,255),math.random(0,255))
	else
		BColor = WeaponData.TracerColor
	end

	if Visivel then
		if gameRules.ReplicatedBullets then
			Evt.ServerBullet:FireServer(Origin,Direction,WeaponData,ModTable)
		end

		if WeaponData.Tracer == true then

			local At1 = Instance.new("Attachment")
			At1.Name = "At1"
			At1.Position = Vector3.new(-(.05),0,0)
			At1.Parent = Bullet

			local At2  = Instance.new("Attachment")
			At2.Name = "At2"
			At2.Position = Vector3.new((.05),0,0)
			At2.Parent = Bullet

			local Particles = Instance.new("Trail")
			Particles.Transparency = NumberSequence.new({
				NumberSequenceKeypoint.new(0, 0, 0);
				NumberSequenceKeypoint.new(1, 1);
			}
			)
			Particles.WidthScale = NumberSequence.new({
				NumberSequenceKeypoint.new(0, 2, 0);
				NumberSequenceKeypoint.new(1, 1);
			}
			)


			Particles.Color = ColorSequence.new(BColor)
			Particles.Texture = "rbxassetid://232918622"
			Particles.TextureMode = Enum.TextureMode.Stretch

			Particles.FaceCamera = true
			Particles.LightEmission = 1
			Particles.LightInfluence = 0
			Particles.Lifetime = .25
			Particles.Attachment0 = At1
			Particles.Attachment1 = At2
			Particles.Parent = Bullet
		end

		if WeaponData.BulletFlare == true then
			local bg = Instance.new("BillboardGui", Bullet)
			bg.Adornee = Bullet
			bg.Enabled = false
			local flashsize = math.random(275, 375)/10
			bg.Size = UDim2.new(flashsize, 0, flashsize, 0)
			bg.LightInfluence = 0
			local flash = Instance.new("ImageLabel", bg)
			flash.BackgroundTransparency = 1
			flash.Size = UDim2.new(1, 0, 1, 0)
			flash.Position = UDim2.new(0, 0, 0, 0)
			flash.Image = "http://www.roblox.com/asset/?id=1047066405"
			flash.ImageTransparency = math.random(2, 5)/15
			flash.ImageColor3 = BColor

			spawn(function()
				wait(.1)
				if not Bullet:FindFirstChild("BillboardGui") then return; end;
				Bullet.BillboardGui.Enabled = true
			end)
		end

	end

	local BulletMass = Bullet:GetMass()
	local Force = Vector3.new(0,BulletMass * (196.2) - (WeaponData.BulletDrop) * (196.2), 0)
	local BF = Instance.new("BodyForce",Bullet)

	Bullet.CFrame = BulletCF
	Bullet:ApplyImpulse(Direction * WeaponData.MuzzleVelocity * ModTable.MuzzleVelocity)
	BF.Force = Force

	game.Debris:AddItem(Bullet, 5)

	CastRay(Bullet, Origin)
end


function meleeCast()

	local recast
	-- Set an origin and directional vector
	local rayOrigin 	= cam.CFrame.Position
	local rayDirection 	= cam.CFrame.LookVector * WeaponData.BladeRange

	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = Ignore_Model
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	raycastParams.IgnoreWater = true
	local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)


	if raycastResult then
		local Hit2 = raycastResult.Instance

		--Check if it's a hat or accessory
		if Hit2 and Hit2.Parent:IsA('Accessory') then
			for _,players in pairs(game.Players:GetPlayers()) do
				if not players.Character then continue; end;
				for i, hats in pairs(players.Character:GetChildren()) do
					if not hats:IsA("Accessory") then continue; end;
					table.insert(Ignore_Model, hats)
				end
			end
			return meleeCast()
		end

		if Hit2 and Hit2.Name == "Ignorable" or Hit2.Name == "Ignore" or Hit2.Parent.Name == "Top" or Hit2.Parent.Name == "Helmet" or Hit2.Parent.Name == "Up" or Hit2.Parent.Name == "Down" or Hit2.Parent.Name == "Face" or Hit2.Parent.Name == "Olho" or Hit2.Parent.Name == "Headset" or Hit2.Parent.Name == "Numero" or Hit2.Parent.Name == "Vest" or Hit2.Parent.Name == "Chest" or Hit2.Parent.Name == "Waist" or Hit2.Parent.Name == "Back" or Hit2.Parent.Name == "Belt" or Hit2.Parent.Name == "Leg1" or Hit2.Parent.Name == "Leg2" or Hit2.Parent.Name == "Arm1"  or Hit2.Parent.Name == "Arm2" then
			table.insert(Ignore_Model, Hit2)
			return meleeCast()
		end

		if Hit2 and Hit2.Parent.Name == "Top" or Hit2.Parent.Name == "Helmet" or Hit2.Parent.Name == "Up" or Hit2.Parent.Name == "Down" or Hit2.Parent.Name == "Face" or Hit2.Parent.Name == "Olho" or Hit2.Parent.Name == "Headset" or Hit2.Parent.Name == "Numero" or Hit2.Parent.Name == "Vest" or Hit2.Parent.Name == "Chest" or Hit2.Parent.Name == "Waist" or Hit2.Parent.Name == "Back" or Hit2.Parent.Name == "Belt" or Hit2.Parent.Name == "Leg1" or Hit2.Parent.Name == "Leg2" or Hit2.Parent.Name == "Arm1"  or Hit2.Parent.Name == "Arm2" then
			table.insert(Ignore_Model, Hit2.Parent)
			return meleeCast()
		end

		if Hit2 and (Hit2.Transparency >= 1 or Hit2.CanCollide == false) and Hit2.Name ~= 'Head' and Hit2.Name ~= 'Right Arm' and Hit2.Name ~= 'Left Arm' and Hit2.Name ~= 'Right Leg' and Hit2.Name ~= 'Left Leg' and Hit2.Name ~= "UpperTorso" and Hit2.Name ~= "LowerTorso" and Hit2.Name ~= "RightUpperArm" and Hit2.Name ~= "RightLowerArm" and Hit2.Name ~= "RightHand" and Hit2.Name ~= "LeftUpperArm" and Hit2.Name ~= "LeftLowerArm" and Hit2.Name ~= "LeftHand" and Hit2.Name ~= "RightUpperLeg" and Hit2.Name ~= "RightLowerLeg" and Hit2.Name ~= "RightFoot" and Hit2.Name ~= "LeftUpperLeg" and Hit2.Name ~= "LeftLowerLeg" and Hit2.Name ~= "LeftFoot" and Hit2.Name ~= 'Armor' and Hit2.Name ~= 'EShield' then
			table.insert(Ignore_Model, Hit2)
			return meleeCast()
		end
	end


	if not raycastResult then return; end;
	local FoundHuman,VitimaHuman = CheckForHumanoid(raycastResult.Instance)
	HitMod.HitEffect(Ignore_Model, raycastResult.Position, raycastResult.Instance , raycastResult.Normal, raycastResult.Material, WeaponData)
	Evt.HitEffect:FireServer(raycastResult.Position, raycastResult.Instance , raycastResult.Normal, raycastResult.Material, WeaponData)

	local HitPart = raycastResult.Instance

	if not FoundHuman or VitimaHuman.Health <= 0 then return; end;
	local SKP_02 = SKP_01.."-"..plr.UserId

	if HitPart.Name == "Head" or HitPart.Parent.Name == "Top" or HitPart.Parent.Name == "Headset" or HitPart.Parent.Name == "Olho" or HitPart.Parent.Name == "Face" or HitPart.Parent.Name == "Numero" then
		Thread:Spawn(function()
			Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, 0, 1, WeaponData, ModTable, nil, nil, SKP_02)	
		end)

	elseif HitPart.Name == "Torso" or HitPart.Name == "UpperTorso" or HitPart.Name == "LowerTorso" or HitPart.Parent.Name == "Chest" or HitPart.Parent.Name == "Waist" or HitPart.Name == "RightUpperArm" or HitPart.Name == "RightLowerArm" or HitPart.Name == "RightHand" or HitPart.Name == "LeftUpperArm" or HitPart.Name == "LeftLowerArm" or HitPart.Name == "LeftHand" then
		Thread:Spawn(function()
			Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, 0, 2, WeaponData, ModTable, nil, nil, SKP_02)	
		end)

	elseif HitPart.Name == "Right Arm" or HitPart.Name == "Right Leg" or HitPart.Name == "Left Leg" or HitPart.Name == "Left Arm" or HitPart.Name == "RightUpperLeg" or HitPart.Name == "RightLowerLeg" or HitPart.Name == "RightFoot" or HitPart.Name == "LeftUpperLeg" or HitPart.Name == "LeftLowerLeg" or HitPart.Name == "LeftFoot" then
		Thread:Spawn(function()
			Evt.Damage:InvokeServer(WeaponTool, VitimaHuman, 0, 3, WeaponData, ModTable, nil, nil, SKP_02)	
		end)
	end;		
end;

function UpdateGui()
	if not SE_GUI or not WeaponData then return; end;
	local HUD = SE_GUI.GunHUD

	HUD.NText.Text = WeaponData.gunName
	HUD.BText.Text = WeaponData.BulletType
	HUD.A.Visible = SafeMode
	HUD.Att.Silencer.Visible = Suppressor
	HUD.Att.Bipod.Visible = BipodAtt
	HUD.Sens.Text = (Sens/100)

	if WeaponData.Jammed then
		HUD.B.BackgroundColor3 = Color3.fromRGB(255,0,0)
	else
		HUD.B.BackgroundColor3 = Color3.fromRGB(255,255,255)
	end

	if Ammo > 0 then
		HUD.B.Visible = true
	else
		HUD.B.Visible = false
	end

	if WeaponData.ShootType == 1 then
		HUD.FText.Text = "Semi"
	elseif WeaponData.ShootType == 2 then
		HUD.FText.Text = "Burst"
	elseif WeaponData.ShootType == 3 then
		HUD.FText.Text = "Auto"
	elseif WeaponData.ShootType == 4 then
		HUD.FText.Text = "Pump-Action"
	elseif WeaponData.ShootType == 5 then
		HUD.FText.Text = "Bolt-Action"
	end

	if WeaponData.EnableZeroing then
		HUD.ZeText.Visible = true
		HUD.ZeText.Text = WeaponData.CurrentZero .." m"
	else
		HUD.ZeText.Visible = false
	end

	if WeaponData.MagCount then
		HUD.SAText.Text = math.ceil(StoredAmmo/WeaponData.Ammo)
		HUD.Magazines.Visible = true
		HUD.Bullets.Visible = false
	else
		HUD.SAText.Text = StoredAmmo
		HUD.Magazines.Visible = false
		HUD.Bullets.Visible = true
	end

	if LaserAtt then
		HUD.Att.Laser.Visible = true
		if LaserActive then
			if IRmode then
				TS:Create(HUD.Att.Laser, TweenInfo.new(.1,Enum.EasingStyle.Linear), {ImageColor3 = Color3.fromRGB(0,255,0), ImageTransparency = .123}):Play()
			else
				TS:Create(HUD.Att.Laser, TweenInfo.new(.1,Enum.EasingStyle.Linear), {ImageColor3 = Color3.fromRGB(255,255,255), ImageTransparency = .123}):Play()
			end
		else
			TS:Create(HUD.Att.Laser, TweenInfo.new(.1,Enum.EasingStyle.Linear), {ImageColor3 = Color3.fromRGB(255,0,0), ImageTransparency = .5}):Play()
		end
	else
		HUD.Att.Laser.Visible = false
	end

	if TorchAtt then
		HUD.Att.Flash.Visible = true
		if TorchActive then
			TS:Create(HUD.Att.Flash, TweenInfo.new(.1,Enum.EasingStyle.Linear), {ImageColor3 = Color3.fromRGB(255,255,255), ImageTransparency = .123}):Play()
		else
			TS:Create(HUD.Att.Flash, TweenInfo.new(.1,Enum.EasingStyle.Linear), {ImageColor3 = Color3.fromRGB(255,0,0), ImageTransparency = .5}):Play()
		end
	else
		HUD.Att.Flash.Visible = false
	end

	if WeaponData.Type == "Grenade" then
		SE_GUI.GrenadeForce.Visible = true
	else
		SE_GUI.GrenadeForce.Visible = false
	end
end

function CheckMagFunction()

	if aimming then
		aimming = false
		ADS(aimming)
	end

	if SE_GUI then
		local HUD = SE_GUI.GunHUD

		TS:Create(HUD.CMText,TweenInfo.new(.25,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{TextTransparency = 0,TextStrokeTransparency = 0.75}):Play()

		if Ammo >= WeaponData.Ammo then
			HUD.CMText.Text = "Full"
		elseif Ammo > math.floor((WeaponData.Ammo)*.75) and Ammo < WeaponData.Ammo then
			HUD.CMText.Text = "Nearly full"
		elseif Ammo < math.floor((WeaponData.Ammo)*.75) and Ammo > math.floor((WeaponData.Ammo)*.5) then
			HUD.CMText.Text = "Almost half"
		elseif Ammo == math.floor((WeaponData.Ammo)*.5) then
			HUD.CMText.Text = "Half"
		elseif Ammo > math.ceil((WeaponData.Ammo)*.25) and Ammo <  math.floor((WeaponData.Ammo)*.5) then
			HUD.CMText.Text = "Less than half"
		elseif Ammo < math.ceil((WeaponData.Ammo)*.25) and Ammo > 0 then
			HUD.CMText.Text = "Almost empty"
		elseif Ammo == 0 then
			HUD.CMText.Text = "Empty"
		end

		delay(.25,function()
			TS:Create(HUD.CMText,TweenInfo.new(.25,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,5),{TextTransparency = 1,TextStrokeTransparency = 1}):Play()
		end)
	end
	mouse1down 	= false
	SafeMode 	= false
	GunStance 	= 0
	Evt.GunStance:FireServer(GunStance,AnimData)
	UpdateGui()
	MagCheckAnim()
	RunCheck()
end

function Grenade()
	if GRDebounce then return; end;
	GRDebounce = true;
	GrenadeReady()

	repeat wait() until not CookGrenade;
	TossGrenade()
end

function TossGrenade()
	if not WeaponTool or not WeaponData or not GRDebounce then return; end;
	local SKP_02 = SKP_01.."-"..plr.UserId
	GrenadeThrow()
	if not WeaponTool or not WeaponData then return; end;
	Evt.Grenade:FireServer(WeaponTool,WeaponData,cam.CFrame,cam.CFrame.LookVector,Power,SKP_02)
	unset()
end

function GrenadeMode()
	if Power >= 150 then
		Power = 100
		SE_GUI.GrenadeForce.Text = "Mid Throw"
	elseif Power >= 100 then
		Power = 50
		SE_GUI.GrenadeForce.Text = "Low Throw"
	elseif Power >= 50 then
		Power = 150
		SE_GUI.GrenadeForce.Text = "High Throw"
	end
end

function JamChance()
	if not WeaponData or not WeaponData.CanBreak or WeaponData.Jammed or Ammo - 1 <= 0 then return; end;
	local Jam = math.random(1000)
	if Jam > 2 then return; end;
	WeaponData.Jammed = true
	WeaponInHand.Handle.Click:Play()
end

function Jammed()
	if not WeaponData or WeaponData.Type ~= "Gun" or not WeaponData.Jammed then return; end;
	mouse1down = false
	reloading = true
	SafeMode = false
	GunStance = 0
	Evt.GunStance:FireServer(GunStance,AnimData)
	UpdateGui()

	JammedAnim()
	WeaponData.Jammed = false
	UpdateGui()
	reloading = false
	RunCheck()
end

function Reload()
	if WeaponData.Type == "Gun" and StoredAmmo > 0 and (Ammo < WeaponData.Ammo or WeaponData.IncludeChamberedBullet and Ammo < WeaponData.Ammo + 1) then

		mouse1down = false
		reloading = true
		SafeMode = false
		GunStance = 0
		Evt.GunStance:FireServer(GunStance,AnimData)
		UpdateGui()

		if WeaponData.ShellInsert then
			if Ammo > 0 then
				for i = 1,WeaponData.Ammo - Ammo do
					if StoredAmmo > 0 and Ammo < WeaponData.Ammo then
						if CancelReload then
							break
						end
						ReloadAnim()
						Ammo = Ammo + 1
						StoredAmmo = StoredAmmo - 1
						UpdateGui()
					end
				end
			else
				TacticalReloadAnim()
				Ammo = Ammo + 1
				StoredAmmo = StoredAmmo - 1
				UpdateGui()
				for i = 1,WeaponData.Ammo - Ammo do
					if StoredAmmo > 0 and WeaponData and Ammo < WeaponData.Ammo then
						if CancelReload then
							break
						end
						ReloadAnim()
						Ammo = Ammo + 1
						StoredAmmo = StoredAmmo - 1
						UpdateGui()
					end
				end

			end
		else
			if Ammo > 0 then
				ReloadAnim()
			else
				TacticalReloadAnim()
			end
			
			if WeaponData then
				if (Ammo - (WeaponData.Ammo - StoredAmmo)) < 0 then
					Ammo = Ammo + StoredAmmo
					StoredAmmo = 0

				elseif Ammo <= 0 then
					StoredAmmo = StoredAmmo - (WeaponData.Ammo - Ammo)
					Ammo = WeaponData.Ammo

				elseif Ammo > 0 and WeaponData.IncludeChamberedBullet then
					StoredAmmo = StoredAmmo - (WeaponData.Ammo - Ammo) - 1
					Ammo = WeaponData.Ammo + 1

				elseif Ammo > 0 and not WeaponData.IncludeChamberedBullet then
					StoredAmmo = StoredAmmo - (WeaponData.Ammo - Ammo)
					Ammo = WeaponData.Ammo
				end
			end
		end
		
		if WeaponData.Type == "Gun" and WeaponData.IsLauncher then
			Evt.RepAmmo:FireServer(WeaponTool,Ammo,StoredAmmo,WeaponData.Jammed)
		end
		
		CancelReload = false
		reloading = false
		RunCheck()
		UpdateGui()
	end
end

function GunFx()

	-- Clone and play muzzle sound
	local Muzzle = WeaponInHand.Handle.Muzzle
	
	if WeaponData.ShootType > 3 then
		canPump = true
	end

	if Suppressor then
		local newSound = Muzzle.Supressor:Clone()
		newSound.PlaybackSpeed = newSound.PlaybackSpeed + math.random(-20,20) / 1000
		newSound.Parent = Muzzle
		newSound.Name = "Firing"
		newSound:Play()
		newSound.PlayOnRemove = true
		newSound:Destroy()
	else
		local newSound = Muzzle.Fire:Clone()
		newSound.PlaybackSpeed = newSound.PlaybackSpeed + math.random(-20,20) / 1000
		newSound.Parent = Muzzle
		newSound.Name = "Firing"
		newSound:Play()
		newSound.PlayOnRemove = true
		newSound:Destroy()
	end

	if Muzzle:FindFirstChild("Echo") then
		local newSound = Muzzle.Echo:Clone()
		newSound.PlaybackSpeed = newSound.PlaybackSpeed + math.random(-20,20) / 1000
		newSound.Parent = Muzzle
		newSound.Name = "FireEcho"
		newSound:Play()
		newSound.PlayOnRemove = true
		newSound:Destroy()
	end

	if WeaponData.FlashChance and math.random(1,10) <= WeaponData.FlashChance and not FlashHider then
		if Muzzle:FindFirstChild("FlashFX") then
			Muzzle["FlashFX"].Enabled = true
			delay(0.1,function()
				if Muzzle:FindFirstChild("FlashFX") then
					Muzzle["FlashFX"].Enabled = false
				end
			end)
		end
		WeaponInHand.Handle.Muzzle["FlashFX[Flash]"]:Emit(10)
	end
	WeaponInHand.Handle.Muzzle["Smoke"]:Emit(10)

	if BSpread then
		BSpread = math.min(WeaponData.MaxSpread * ModTable.MaxSpread, BSpread + WeaponData.AimInaccuracyStepAmount * ModTable.AimInaccuracyStepAmount)
		RecoilPower =  math.min(WeaponData.MaxRecoilPower * ModTable.MaxRecoilPower, RecoilPower + WeaponData.RecoilPowerStepAmount * ModTable.RecoilPowerStepAmount)
	end

	generateBullet = generateBullet + 1
	LastSpreadUpdate = time()

	if Ammo > 0 or not WeaponData.SlideLock then
		TS:Create( WeaponInHand.Handle.Slide, TweenInfo.new(30/WeaponData.ShootRate,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,true,0), {C0 =  WeaponData.SlideEx:inverse() }):Play()
	elseif Ammo <= 0 and WeaponData.SlideLock then
		TS:Create( WeaponInHand.Handle.Slide, TweenInfo.new(30/WeaponData.ShootRate,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0), {C0 =  WeaponData.SlideEx:inverse() }):Play()
	end
	
	if WeaponData.ShootType < 4 then
		WeaponInHand.Handle.Chamber.Smoke:Emit(10)
	end

	for _, effect in pairs(WeaponInHand.Handle.Chamber:GetChildren()) do
		if effect.Name == "Shell" then
			effect:Emit(1)
		end
	end
end

function ShellCheck()
	if WeaponData.ShellEjectionMod and WeaponData.ShootType < 4 then
		if Engine.AmmoModels:FindFirstChild(WeaponData.BulletType) then
			CreateShell(WeaponData.BulletType,WeaponInHand.Handle.Chamber)
		else
			CreateShell("Default",WeaponInHand.Handle.Chamber)
		end
	end
end

function Shoot()
	if WeaponData and WeaponData.Type == "Gun" and not shooting and not reloading then

		if reloading or runKeyDown or SafeMode or CheckingMag then
			mouse1down = false
			return
		end

		if Ammo <= 0 or WeaponData.Jammed then
			WeaponInHand.Handle.Click:Play()
			mouse1down = false
			return
		end

		mouse1down = true

		delay(0, function()
			if WeaponData and WeaponData.ShootType == 1 then 
				shooting = true	
				Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)
				ShellCheck()
				for _ =  1, WeaponData.Bullets do
					Thread:Spawn(CreateBullet)
				end
				Ammo = Ammo - 1
				GunFx()
				JamChance()
				UpdateGui()
				Thread:Spawn(Recoil)
				wait(60/WeaponData.ShootRate)
				shooting = false

			elseif WeaponData and WeaponData.ShootType == 2 then
				for i = 1, WeaponData.BurstShot do
					if shooting or Ammo <= 0 or mouse1down == false or WeaponData.Jammed then
						break
					end
					shooting = true	
					Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)
					ShellCheck()
					for _ =  1, WeaponData.Bullets do
						Thread:Spawn(CreateBullet)
					end
					Ammo = Ammo - 1
					GunFx()
					JamChance()
					UpdateGui()
					Thread:Spawn(Recoil)
					wait(60/WeaponData.ShootRate)
					shooting = false

				end
			elseif WeaponData and WeaponData.ShootType == 3 then
				while mouse1down do
					if shooting or Ammo <= 0 or WeaponData.Jammed then
						break
					end
					shooting = true	
					Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)
					ShellCheck()
					for _ =  1, WeaponData.Bullets do
						Thread:Spawn(CreateBullet)
					end
					Ammo = Ammo - 1
					GunFx()
					JamChance()
					UpdateGui()
					Thread:Spawn(Recoil)
					wait(60/WeaponData.ShootRate)
					shooting = false

				end
			elseif WeaponData and WeaponData.ShootType == 4 or WeaponData and WeaponData.ShootType == 5 then
				shooting = true	
				Evt.Atirar:FireServer(WeaponTool,Suppressor,FlashHider)
				for _ =  1, WeaponData.Bullets do
					Thread:Spawn(CreateBullet)
				end
				Ammo = Ammo - 1
				GunFx()
				UpdateGui()
				Thread:Spawn(Recoil)
				PumpAnim()
				RunCheck()
				shooting = false

			end
			
			if WeaponData and WeaponData.Type == "Gun" and WeaponData.IsLauncher then
				Evt.RepAmmo:FireServer(WeaponTool,Ammo,StoredAmmo,WeaponData.Jammed)
			end
		end)

	elseif WeaponData and WeaponData.Type == "Melee" and not runKeyDown then
		if not shooting then
			shooting = true
			meleeCast()
			meleeAttack()
			RunCheck()
			shooting = false
		end
	end
end

local L_150_ = {}

local LeanSpring = {}
LeanSpring.cornerPeek = SpringMod.new(0)
LeanSpring.cornerPeek.d = 1
LeanSpring.cornerPeek.s = 20
LeanSpring.peekFactor = math.rad(-15)
LeanSpring.dirPeek = 0

function L_150_.Update()

	LeanSpring.cornerPeek.t = LeanSpring.peekFactor * Virar
	local NewLeanCF = CFrame.fromAxisAngle(Vector3.new(0, 0, 1), LeanSpring.cornerPeek.p)
	cam.CFrame = cam.CFrame * NewLeanCF
end

game:GetService("RunService"):BindToRenderStep("Camera Update", 200, L_150_.Update)

function RunCheck()
	if runKeyDown then
		mouse1down = false
		GunStance = 3
		Evt.GunStance:FireServer(GunStance,AnimData)
		SprintAnim()
	else
		if aimming then
			GunStance = 2
			Evt.GunStance:FireServer(GunStance,AnimData)
		else
			GunStance = 0
			Evt.GunStance:FireServer(GunStance,AnimData)
		end
		IdleAnim()
	end
end

function Stand()
	Stance:FireServer(Stances,Virar)
	TS:Create(char.Humanoid, TweenInfo.new(.3), {CameraOffset = Vector3.new(CameraX,CameraY,char.Humanoid.CameraOffset.Z)} ):Play()

	SE_GUI.MainFrame.Poses.Levantado.Visible = true
	SE_GUI.MainFrame.Poses.Agaixado.Visible = false
	SE_GUI.MainFrame.Poses.Deitado.Visible = false

	--if Steady then
	--	SetWalkSpeed(gameRules.SlowPaceWalkSpeed)
	--else
	--	if script.Parent:GetAttribute("Injured") then
	--		SetWalkSpeed(gameRules.InjuredWalksSpeed)
	--	else
	--		SetWalkSpeed(gameRules.NormalWalkSpeed)
	--	end
	--end
	char.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
	IsStanced = false	

end

function Crouch()
	Stance:FireServer(Stances,Virar)
	TS:Create(char.Humanoid, TweenInfo.new(.3), {CameraOffset = Vector3.new(CameraX,CameraY,char.Humanoid.CameraOffset.Z)} ):Play()

	SE_GUI.MainFrame.Poses.Levantado.Visible = false
	SE_GUI.MainFrame.Poses.Agaixado.Visible = true
	SE_GUI.MainFrame.Poses.Deitado.Visible = false

	--if script.Parent:GetAttribute("Injured") then
	--	SetWalkSpeed(gameRules.InjuredCrouchWalkSpeed)
	--else
	--	SetWalkSpeed(gameRules.CrouchWalkSpeed)
	--end
	char.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	IsStanced = true	
end

function Prone()
	Stance:FireServer(Stances,Virar)
	TS:Create(char.Humanoid, TweenInfo.new(.3), {CameraOffset = Vector3.new(CameraX,CameraY,char.Humanoid.CameraOffset.Z)} ):Play()

	SE_GUI.MainFrame.Poses.Levantado.Visible = false
	SE_GUI.MainFrame.Poses.Agaixado.Visible = false
	SE_GUI.MainFrame.Poses.Deitado.Visible = true

	--if ACS_Client:GetAttribute("Surrender") then
	--	char.Humanoid.WalkSpeed = 0
	--else
	--	SetWalkSpeed(gameRules.ProneWalksSpeed)
	--end

	char.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	IsStanced = true
end

function Lean()
	TS:Create(char.Humanoid, TweenInfo.new(.3), {CameraOffset = Vector3.new(CameraX,CameraY,char.Humanoid.CameraOffset.Z)} ):Play()
	Stance:FireServer(Stances,Virar)

	if Virar == 0 then
		SE_GUI.MainFrame.Poses.Esg_Left.Visible = false
		SE_GUI.MainFrame.Poses.Esg_Right.Visible = false
	elseif Virar == 1 then
		SE_GUI.MainFrame.Poses.Esg_Left.Visible = false
		SE_GUI.MainFrame.Poses.Esg_Right.Visible = true
	elseif Virar == -1 then
		SE_GUI.MainFrame.Poses.Esg_Left.Visible = true
		SE_GUI.MainFrame.Poses.Esg_Right.Visible = false
	end
end
