Skip to content

Instantly share code, notes, and snippets.

@Aerodos12
Created July 20, 2018 15:34
Show Gist options
  • Save Aerodos12/78ab93fc2ae384ffce72cec495ff5381 to your computer and use it in GitHub Desktop.
Save Aerodos12/78ab93fc2ae384ffce72cec495ff5381 to your computer and use it in GitHub Desktop.
Current GunCode
local RemoteService = require(game.ReplicatedStorage.RemoteService)
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local CAS = game:GetService("ContextActionService")
local player = game.Players.LocalPlayer
local Signal = require(game.ReplicatedStorage.SignalAPI)
local Bindables = game.ReplicatedStorage.Bindables:Clone()
Bindables.Parent = player
local BindableService = require(game.ReplicatedStorage.BindingService)(player)
local CameraService = require(game.ReplicatedStorage.CameraService)
local AfterEffects = require(game.ReplicatedStorage.GunLibraries.AfterEffect)
local TweenService = game:GetService("TweenService")
local Cartridges = require(game.ReplicatedStorage.Settings.Cartridges)
local Utils = require(game.ReplicatedStorage.UtilService)
local EasingEasel = Utils.CreateGameObject("EasingEasel",90)
local InputComp = require(game.ReplicatedStorage.InputComponent)
local RAD = Utils.Math.RAD;
local COS = Utils.Math.COS;
local SIN = Utils.Math.SIN;
local GunPickup = nil
local OBJ = Instance.new
local Character = nil;
local tween
local Bolt
local CF = {
RAW = CFrame.new,
ANG = CFrame.Angles,
ID = CFrame.new();
Inverse = CFrame.new().inverse,
TOS = CFrame.new().toObjectSpace
}
CF.FAxAR = CFrame.fromAxisAngle
CF.FAxA = function(x,y,z)
if not y then
x,y,z=x.x,x.y,x.z
end
local m=(x*x+y*y+z*z)^0.5
if m>1e-5 then
local si=SIN(m/2)/m
return CF.RAW(0,0,0,si*x,si*y,si*z,COS(m/2))
else
return CF.ID
end
end
local V3 = Vector3.new
local VEC2 = Vector2.new
local RAY = {
RAW = Ray.new;
CAST = workspace.FindPartOnRayWithIgnoreList;
}
local Sequences = {
Color = {
Raw = ColorSequence.new;
Keypoint = ColorSequenceKeypoint.new;
};
Number = {
Raw = NumberSequence.new;
Keypoint = NumberSequenceKeypoint.new;
}
}
local gunRecoilSpring = Utils.CreateSpring("Vector3",V3())
gunRecoilSpring.s = 15;
gunRecoilSpring.d = 0.5
local NRANGE = NumberRange.new
local FFC = game.FindFirstChild
local RNG = Random.new()
local MIN = math.min
local MAX = math.max
local runAsync = function(f) coroutine.resume(coroutine.create(f)) end
local Debris = game:GetService("Debris")
local Duration1 = .26
local Duration2 = 30
local IGSEnabled = false
local lastSideRecoil = {0, 0}
local recoilAnim = {
Pos = V3();
Rot = V3();
Code = nil;
}
local HitSounds = {
"285421759";
"151130102";
"151130171";
"285421804";
"287769483";
"287769415";
"285421687";
"287769261";
"287772525";
"287772445";
"287772351";
"285421819";
"287772163";
}
local HitMaterials = {
Enum.Material.Plastic;
Enum.Material.Slate;
Enum.Material.Concrete;
Enum.Material.CorrodedMetal;
Enum.Material.DiamondPlate;
Enum.Material.Foil;
Enum.Material.Marble;
Enum.Material.Granite;
Enum.Material.Brick;
Enum.Material.Grass;
Enum.Material.Pebble;
Enum.Material.SmoothPlastic;
Enum.Material.Metal;
Enum.Material.Cobblestone;
};
CameraService:setCamMode("IntermissionMenu","Main")
local BulletHEntries = {}
local HController = require(script.Parent:WaitForChild("HUDController",200))
local PingDeath = Signal:Create()
local deathRecieve = tick()
local HudController
local Humanoid
local ItemEquipped = Signal:Create()
local ItemUnequipped = Signal:Create()
local IEC, IUEC, IAC, IBE, IEE;
local CameraAng = VEC2(0,0);
local CharState = {}
local CameraState = {}
local BoltWelds = {}
local boltAnim = {}
local Keybinds
local function changeKeybindIMode(itemType)
if UIS.GamepadEnabled and #UIS:GetConnectedGamepads() > 0 then
Keybinds = RemoteService.fetch("Server","GetKeybinds","Gamepad",itemType);
elseif UIS.KeyboardEnabled then
Keybinds = RemoteService.fetch("Server","GetKeybinds","Keyboard",itemType);
end
end
do
CameraState.camOffsets = {
guiScope = {
Rot = V3();
};
Reload = {
Rot = V3();
Code = nil;
};
Recoil = {
Rot = V3();
Code = nil;
};
}
CameraState.camRecoilSpring = Utils.CreateSpring("Vector3",V3())
CameraState.camRecoilSpring.s = 35
CameraState.camRecoilSpring.d = 0.5
end
local crawlReady = false
do
local crawlCamRot = 0;
local walkSpeedSpring = Utils.CreateGameObject("Spring","Number",14)
walkSpeedSpring.s = 8
local WalkSpeedMult = 1;
local currentState = "Idling";
local Stance = 0;
CharState.calcWalkSpeed = function(self,baseWalkSpeed)
if not Keybinds then return 1 * WalkSpeedMult * baseWalkSpeed/math.clamp(Stance*2,1,8) end
return (((InputComp:IsInputDown(Enum.KeyCode[Keybinds.Sprint]) and self.Stance == 0 ) and 1.5 or 1) * WalkSpeedMult * baseWalkSpeed/math.clamp(Stance*2,1,8))
end
local crawlAlpha = 0
local idleAlpha = 1
local walkAlpha = 0
local runAlpha = 0
local aimAlpha = 0
local stanceSway = 1
local onGround = true
local RunningTrans = "None";
local aimHeadOffset = 0;
local armTiltMultiplier = 0;
local jumpAnimMultiplier = 1;
local armTilt = 0;
local runReady = true;
local desiredXOffset = 0
local desiredYOffset = 0
local currentXOffset = 0
local currentYOffset = 0
local rotationMultiplier = 5
local crawlAng = 0
local moveAng = 0
local jumpAnim = {
Pos = 0;
Rot = 0;
Code = 0;
}
local Anim = {
Pos = V3();
Rot = V3();
Ang = 0;
Code = 0;
}
CharState.animCF = {
gun = function(...)
local args = {...}
local t = args[1];
if t == "General" then
return CF.RAW(aimHeadOffset,0,0) * CF.ANG(
(jumpAnim.Rot * COS(CameraAng.Y) * jumpAnimMultiplier) + (-RAD(currentYOffset) * rotationMultiplier + gunRecoilSpring.p.X + Anim.Rot.X) * stanceSway,
(gunRecoilSpring.p.Y + Anim.Rot.Y) * stanceSway,
(gunRecoilSpring.p.Z + Anim.Rot.Z) * stanceSway
) * CF.RAW(
(recoilAnim.Pos.X + Anim.Pos.X) * stanceSway,
(jumpAnim.Pos * COS(CameraAng.Y) * jumpAnimMultiplier) + (recoilAnim.Pos.Y + Anim.Pos.Y) * stanceSway,
(-jumpAnim.Pos * SIN(CameraAng.Y) * jumpAnimMultiplier) + (recoilAnim.Pos.Z + Anim.Pos.Z) * stanceSway
),
CF.ANG(-CameraAng.Y * crawlAlpha / 90, 0, 0) * CF.RAW(aimHeadOffset,-1,0) ---CF.ANG(COS(CameraAng.Y) * (gunRecoilSpring.p.X + Anim.Rot.X) * stanceSway,(gunRecoilSpring.p.Y + Anim.Rot.Y) * stanceSway, (gunRecoilSpring.p.Z + Anim.Rot.Z) * stanceSway) * CF.RAW((recoilAnim.Pos.X + Anim.Pos.X) * stanceSway,COS(CameraAng.Y) * (recoilAnim.Pos.Y + Anim.Pos.Y) * stanceSway,SIN(CameraAng.Y) * (recoilAnim.Pos.Z + Anim.Pos.Z) * stanceSway),CF.RAW(aimHeadOffset, -1, 0);
elseif t == "Bolt" then
local args = {...}
local key = args[2]
return CF.RAW(boltAnim[key].Kick.X,boltAnim[key].Kick.Y,boltAnim[key].Kick.Z) * CF.ANG(RAD(boltAnim[key].Rot.Y),RAD(boltAnim[key].Rot.X),RAD(boltAnim[key].Rot.Z))
end
end;
grenade = function()
return CF.RAW() * CF.ANG(COS(CameraAng.Y) * Anim.Rot.X * stanceSway,Anim.Rot.Y * stanceSway,Anim.Rot.Z * stanceSway) * CF.RAW(Anim.Pos.X * stanceSway,COS(CameraAng.Y) * Anim.Pos.Y * stanceSway,SIN(CameraAng.Y) *Anim.Pos.Z *stanceSway), CF.RAW(0,-1,0);
end;
};
CharState.setRecoilCode = function(self,code)
recoilAnim.Code = code
end
CharState.setRecoilPos = function(self,pos)
recoilAnim.Pos = pos
end
CharState.setRecoilRot = function(self,rot)
recoilAnim.Rot = rot
end
RunService:BindToRenderStep("UpdateRecoil",Enum.RenderPriority.Character.Value,function(dt)
gunRecoilSpring.t = recoilAnim.Rot
end)
CharState.getHeadOffset = function(self,S)
return VEC2(COS(RAD(90) - S.aimSettings.headTilt) * 0.5, 1 + SIN(RAD(90) - S.aimSettings.headTilt) * 0.5)
end;
CharState = setmetatable(CharState,{
__index = function(self,k)
local key = k:lower()
if key == "crawlcamrot" then
return crawlCamRot;
elseif key == "walkspeed" then
return walkSpeedSpring.t;
elseif key == "walkspeedmulti" then
return WalkSpeedMult;
elseif key == "stance" then
return Stance
elseif key == "grounded" then
return onGround
elseif key == "currentstate" then
return currentState
elseif key == "crawlalpha" then
return crawlAlpha
elseif key == "walkalpha" then
return walkAlpha
elseif key == "runalpha" then
return runAlpha
elseif key == "idlealpha" then
return idleAlpha
elseif key == "aimalpha" then
return aimAlpha
elseif key == "stancesway" then
return stanceSway
elseif key == "baseanim" then
return Anim
elseif key == "runningtrans" then
return RunningTrans
elseif key == "aimheadoffset" then
return aimHeadOffset
elseif key == "armtilt" then
return armTilt
elseif key == "armtiltmultiplier" then
return armTiltMultiplier
elseif key == "jumpanimmultiplier" then
return jumpAnimMultiplier
elseif key == "runready" then
return runReady
elseif key == "crawlang" then
return crawlAng
elseif key == "moveang" then
return moveAng
else
return nil;
end
end;
__newindex = function(self,k,v)
local key = k:lower()
if key == "walkspeed" then
walkSpeedSpring.t = v
elseif key == "stance" then
Stance = v
elseif key == "grounded" then
onGround = v
elseif key == "currentstate" then
currentState = v
elseif key == "crawlalpha" then
crawlAlpha = v
elseif key == "walkalpha" then
walkAlpha = v
elseif key == "runalpha" then
runAlpha = v
elseif key == "idlealpha" then
idleAlpha = v
elseif key == "aimalpha" then
aimAlpha = v
elseif key == "stancesway" then
stanceSway = v
elseif key == "baseanim" then
Anim = v
elseif key == "runningtrans" then
RunningTrans = v
elseif key == "aimheadoffset" then
aimHeadOffset = v
elseif key == "armtilt" then
armTilt = v
elseif key == "armtiltmultiplier" then
armTiltMultiplier = v
elseif key == "jumpanimmultiplier" then
jumpAnimMultiplier = v
elseif key == "runready" then
runReady = v
elseif key == "crawlang" then
crawlAng = v
elseif key == "moveang" then
moveAng = v
end
end
})
end
local Connections = {
Grenade = {};
Gun = {};
}
local CharacterParts = {
Torso = nil;
LArm = nil;
RArm = nil;
LLeg = nil;
RLeg = nil;
Head = nil;
HRP = nil;
};
local armC0 = {
CF.RAW(-1.5, 0, 0) * CF.ANG(RAD(90), 0, 0);
CF.RAW(1.5, 0, 0) * CF.ANG(RAD(90), 0, 0);
}
local legC0 = {
Stand = {
CF.RAW(-0.5, -2, 0);
CF.RAW(0.5, -2, 0);
};
Crouch = {
CF.RAW(-0.5, -1.5, 0.5) * CF.ANG(-RAD(90), 0, 0);
CF.RAW(0.5, -1, -0.75);
};
Prone = {
CF.RAW(-0.5, -2, 0);
CF.RAW(0.5, -2, 0);
};
};
local ViewModel = {
gunIgnore = nil;
playerFolder = nil;
headWeld = nil;
headWeld2 = nil;
armBase = nil;
animWeld = nil;
ABWeld = nil;
LWeld = nil;
RWeld = nil;
LWeld2 = nil;
RWeld2 = nil;
LLegWeld = nil;
RLegWeld = nil;
Grips = {
Left = nil;
Right = nil;
Current = "Right";
};
armModel = nil;
fakeLArm = nil;
fakeRArm = nil;
fakeHumanoid = nil;
fakeLWeld = nil;
fakeRWeld = nil;
}
local getTotalCamOffset = {
grenade = function()
return V3();
end;
gun = function()
return CameraState.camOffsets.guiScope.Rot + CameraState.camOffsets.Reload.Rot + CameraState.camRecoilSpring.p
end
}
local CharacterJoints = {
Neck = nil;
Hips = {
Left = nil;
Right = nil;
};
Shoulders = {
Right = nil;
Left = nil;
};
Root = nil;
}
local Ignore = {
workspace.ignoreModel;
}
function makeHole(H,P,N,D,humanoidFound,S)
local surfaceCF =CF.RAW(P,P + N)
if not H then return end
----------------------------------------------------------------------------------
--Creating the bullet hole--------------------------------------------------------
----------------------------------------------------------------------------------
local Hole = OBJ("Part")
Hole.Transparency = 1
Hole.Anchored = true
Hole.CanCollide = false
Hole.Size = V3(1, 1, 0.2)
Hole.TopSurface = 0
Hole.BottomSurface = 0
if ((not humanoidFound)) then
local Decal = OBJ("Decal")
Decal.Face = Enum.NormalId.Front
Decal.Texture = "rbxassetid://64291977"
Decal.Parent = Hole
Hole.Parent = workspace.HoleStorage
Hole.CFrame = surfaceCF
if (not H.Anchored) then
local Weld = OBJ("Weld")
Weld.Part0 = H
Weld.Part1 = Hole
Weld.Parent = Hole
Weld.C0 = H.CFrame:toObjectSpace(surfaceCF)
Hole.Anchored = false
end
delay(3, function()
Hole:Destroy()
end)
end
----------------------------------------------------------------------------------
--Creating the spark effect-------------------------------------------------------
----------------------------------------------------------------------------------
local mat = H.Material
local sId, sVol, sPitch
sId, sVol, sPitch = HitSounds[math.random(1, #HitSounds)], math.random(0.8, 1), math.random(0, 0.6)
local HitSound = Instance.new("Sound")
HitSound.Name = "HitSound"
HitSound.SoundId = "rbxassetid://" .. sId
HitSound.Volume = 1 + sVol
HitSound.EmitterSize = 10
HitSound.MaxDistance = 90
HitSound.Pitch = sPitch
HitSound.Parent = Hole
HitSound:Play()
game.Debris:AddItem(HitSound,1)
if S.roundsPerMin <= 780 then
if (not humanoidFound) then
local Particles = game.ReplicatedStorage.GunEffectAssets.Sparks:Clone()
Particles:Emit(8)
Particles.Parent = Hole
game.Debris:AddItem(Particles,1)
end
if (not humanoidFound) then
local Particles = game.ReplicatedStorage.GunEffectAssets.Smoke:Clone()
Particles.Color = ColorSequence.new(H.Color);
Particles:Emit(8)
Particles.Parent = Hole
game.Debris:AddItem(Particles,1)
end
end
----------------------------------------------------------------------------------
--Creating the smoke effect-------------------------------------------------------
----------------------------------------------------------------------------------
RemoteService.send("Server","bulletImpact",H, P, N, D, humanoidFound, ViewModel.gunIgnore)
end
local function currentGripArm()
return ViewModel.Grips.Current == "Left" and CharacterParts.LArm or CharacterParts.RArm
end
local CurrentItem do
local item = nil;
local S = nil;
local Type = nil;
local Animations = nil;
local grenadeTable = {};
local breakReload = false;
local magVisible = true;
local magTable = {};
local Ammo = nil;
local ClipSize = nil;
local StoredAmmo = nil;
local FiringSystem = nil;
local Main = {};
local SlidePart
local canSelectFire = true;
local Equipped = false;
local Aimed = false;
local Aiming = false;
local spreadZoom = "unAimed"
local spreadStance = "Stand"
local spreadMotion = "Idling"
local AimPart = nil;
local currentSpread = 0;
local ammoInClip = 0;
local spread = 0;
local crossOffset = 0;
local crossSpring;
local CurrentCartridge = nil;
local newMag = false
local Reloading = false
local crossScale = Utils.CreateGameObject("Spring","Number",1)
crossScale.s = 12
crossScale.d = 0.8
local canFire = true;
local Firing = false;
local shotCount = 0;
local PenetrationTries = 5;
local loweringSpread = false;
local magVisible = true
local isWallIgnored = function(Wall)
return (
Wall.Transparency >= S.penetrationSettings.transparencyThreshold or
(S.penetrationSettings.ignoreNonCanCollide and (not Wall.CanCollide))
)
end;
local projectileTypes = {
Gun = function()
local fireSound = FFC(CurrentItem:getFirePort(1),"FireSound")
tween("Bolt","Main",S.boltSettings.Kick,S.boltSettings.Rot,EasingEasel:getAlpha("Quad@Out"),0.05)
if fireSound then
if S.fireSoundSettings then
if S.fireSoundSettings.useSoundRemover then
local fireSoundC = fireSound:Clone()
fireSoundC.Parent = CurrentItem:getFirePort(1)
fireSoundC:Play()
fireSoundC.Ended:connect(function()
fireSoundC:Destroy()
end)
else
fireSound.TimePosition = S.fireSoundSettings.Start
fireSound:Play()
end
else
fireSound:Play()
end
end
----------------------------------------------------------------------------------
for _ = 1, (S.gunType.Shot and S.shotAmount or 1) do
local spreadDir
if S.gunType.Shot then
local randSpread1 = RAD(Utils.RAND(0, 365))
local randSpread2 = RAD(Utils.RAND(-(CurrentItem.baseSpread + currentSpread), CurrentItem.baseSpread + CurrentItem.currentSpread, 0.01))
spreadDir = CF.FAxA(V3(0, 0, 1) * randSpread1) * CF.ANG(randSpread2, 0, 0)
end
local originCF = ((Aimed and S.guiScope) and CharacterParts.Head.CFrame or item.HoldPart.CFrame)
if spreadDir then
originCF = originCF * spreadDir
end
local bulletDirection = CF.RAW(originCF.p, originCF.p + originCF.lookVector).lookVector
if CurrentCartridge.InstantHit then
local newRay
if S.guiScope then
newRay = HudController:getVPRay()
newRay = RAY.RAW(newRay.Origin,newRay.Direction * CurrentCartridge.Range)
else
newRay = RAY.RAW(CurrentItem:getFirePort(1).CFrame.p, bulletDirection * CurrentCartridge.Range)
end
local H, P, N = RAY.CAST(workspace,newRay, Ignore)
local finalP = P
if H then
if S.gunType.Explosive then
RemoteService.send("Server","FireExplosive",ViewModel.gunIgnore,H,P,N,bulletDirection,Ignore,CurrentItem:getFirePort(1))
else
_, finalP = CurrentItem:penetrateWall(H, P, bulletDirection, N, Ignore, 0, (P - CurrentItem:getFirePort(1).CFrame.p).magnitude, nil)
end
end
else
local bullet = CurrentItem:createBullet(bulletDirection,1)
--Gun.BulletObj.Value = bullet
local debounceParts = {}
bullet.Touched:connect(function(hit)
if (not debounceParts[hit]) and (bullet.CFrame.p - CurrentItem:getFirePort(1).CFrame.p).magnitude <= CurrentCartridge.Range then
debounceParts[hit] = true
local newRay = RAY.RAW(CurrentItem:getFirePort(1).CFrame.p, (bullet.CFrame.p - CurrentItem:getFirePort(1).CFrame.p))
local H, P, N = RAY.CAST(workspace, newRay, Ignore)
local finalP = P
if S.gunType.Explosive then
if (not hit:isDescendantOf(Character) and not hit:isDescendantOf(workspace.ignoreModel)) and not isWallIgnored(hit) then
RemoteService.send("Server","FireExplosive",S,item,ViewModel.gunIgnore,hit,P,N,bulletDirection,Ignore,CurrentItem:getFirePort(1))
OBJ.Destroy(bullet)
end
else
if (not hit:isDescendantOf(Character) and not hit:isDescendantOf(workspace.ignoreModel)) and not isWallIgnored(hit) then
makeHole(hit, P, N, bulletDirection, false, S)
CurrentItem:penetrateWall(hit, P, bullet.CFrame.lookVector, N, Ignore, 0, (bullet.CFrame.p - CurrentItem:getFirePort(1).CFrame.p).magnitude, nil)
--penetrateWall(H, P, bulletDirection, N, {Char, ignoreModel}, 0, (P - Main.CFrame.p).magnitude, nil)
if (bullet.CFrame.p - CurrentItem:getFirePort(1).CFrame.p).magnitude > CurrentCartridge.Range then
OBJ.Destroy(bullet)
else
debounceParts[hit] = false
end
end
end
end
end)
end
end
----------------------------------------------------------------------------------
currentSpread = currentSpread + S.spreadSettings.Increase
--[[
for i = 1,#Libraries.Plugins.Firing do
runAsync(function()
Libraries.Plugins.Firing[i](Player)
end)
end
]]--
local backRecoil = Utils.RAND(S.recoilSettings.Recoil.Back.Min, S.recoilSettings.Recoil.Back.Max, 0.01) --Get the kickback recoil
local upRecoil = Utils.RAND(S.recoilSettings.Recoil.Up.Min, S.recoilSettings.Recoil.Up.Max, 0.01) --Get the up recoil
local sideRecoilAlpha = 0
if lastSideRecoil[1] < 0 and lastSideRecoil[2] < 0 then --This conditional basically makes sure the gun tilt isn't in the same direction for more than 2 shots
sideRecoilAlpha = Utils.RAND(0, 1, 0.1)
elseif lastSideRecoil[1] > 0 and lastSideRecoil[2] > 0 then
sideRecoilAlpha = Utils.RAND(-1, 0, 0.1)
else
sideRecoilAlpha = Utils.RAND(-1, 1, 0.1)
end
local sideRecoil = Utils.numLerp(S.recoilSettings.Recoil.Side.Left, S.recoilSettings.Recoil.Side.Right, sideRecoilAlpha / 2 + 0.5) --Get the side recoil
local tiltRecoil = Utils.numLerp(S.recoilSettings.Recoil.Tilt.Left, S.recoilSettings.Recoil.Tilt.Right, sideRecoilAlpha / 2 + 0.5) --Get the tilt recoil
local recoilPos = V3(
0,---sideRecoil,
0,
-backRecoil
) * 0.5
local recoilRot = V3(
-RAD(upRecoil * 10),
RAD(sideRecoil * 10),
RAD(tiltRecoil * 10)
) * 0.5
local camRecoilRot = V3(
-RAD(sideRecoil * 10),
RAD(upRecoil * 10) * S.recoilSettings.camMultiplier,
0
) * 0.5 * CharState.stanceSway
--Libraries.Haptics.Recoil(1,player)
tween("Recoil",recoilPos, recoilRot, EasingEasel:getAlpha("Sine@Out"), 0.2)
tween("Cam","Recoil", camRecoilRot, EasingEasel:getAlpha("Sine@Out"), 0.15)
CameraState.camRecoilSpring:accelerate(V3(camRecoilRot.X,camRecoilRot.Y,sideRecoilAlpha / 2 + 0.5))
if S.isRevolver then
CurrentItem.revolverMagParts[(item.ClipSize.Value - Ammo.Value)].Transparency = 1
tween("Joint",item.RHPart.CarouselMotor,nil,CF.ANG(0,RAD(-72 * (item.ClipSize.Value - Ammo.Value)),0),EasingEasel:getAlpha("Linear@Out"),0.4)
end
for _, v in pairs(CurrentItem:getFirePort(1):GetChildren()) do
if v.Name:find("FlashFX") then
v.Enabled = true
end
end
RemoteService.send("Server","MuzzleFlash",CurrentItem:getFirePort(1))
delay(0.05 , function()
tween("Recoil",V3(), V3(), EasingEasel:getAlpha("Sine@Out"), 0.2)
tween("Cam","Recoil", V3(), EasingEasel:getAlpha("Sine@Out"), 0.15)
end)
delay(60/S.roundsPerMin, function()
--Libraries.Haptics.Recoil(2,Player)
tween("Bolt","Main",V3(),V3(),EasingEasel:getAlpha("Quad@In"),(60/S.roundsPerMin) )
for _, v in pairs(CurrentItem:getFirePort(1):GetChildren()) do
if v.Name:find("FlashFX") then
v.Enabled = false
end
end
end)
firstShot = false
shotCount = shotCount + 1
lastSideRecoil[(shotCount % 2) + 1] = sideRecoilAlpha
if S.actionType ~= "Gas" then
if S.actionType == "Bolt" then
repeat wait(1/60) until not Aimed
end
CurrentItem:PlayAnimation("Cocking")
end
end;
Grenade = function()
local Cartridge = Cartridges[item.GrenadeCaliber.Value]
CurrentItem:playSound("rbxassetid://135039581",2)
local originCF = ((Aimed and S.guiScope) and CharacterParts.Head.CFrame or item.Handle.CFrame)
local bulletDirection = CF.RAW(originCF.p, originCF.p + originCF.lookVector).lookVector
if Cartridge.InstantHit then
local newRay
if S.guiScope then
newRay = HudController:getVPRay()
newRay = RAY.RAW(newRay.Origin,newRay.Direction * Cartridge.Range)
else
newRay = RAY.RAW(CurrentItem:getFirePort(2).CFrame.p, bulletDirection * Cartridge.Range)
end
local H, P, N = RAY.CAST(workspace,newRay, Ignore)
local finalP = P
if H then
if S.gunType.Explosive then
RemoteService.send("Server","FireExplosive",S, item, ViewModel.gunIgnore,H,P,N,bulletDirection,Ignore)
else
_, finalP = CurrentItem:penetrateWall(H, P, bulletDirection, N, Ignore, 0, (P - CurrentItem:getFirePort(2).CFrame.p).magnitude, nil)
end
end
else
local bullet = CurrentItem:createBullet(bulletDirection,2)
--Gun.BulletObj.Value = bullet
local debounceParts = {}
bullet.Touched:connect(function(hit)
if (not debounceParts[hit]) and (bullet.CFrame.p - CurrentItem:getFirePort(2).CFrame.p).magnitude <= Cartridge.Range then
debounceParts[hit] = true
local newRay = RAY.RAW(CurrentItem:getFirePort(2).CFrame.p, (bullet.CFrame.p - CurrentItem:getFirePort(2).CFrame.p))
local H, P, N = RAY.CAST(workspace,newRay, Ignore)
local finalP = P
if (not hit:isDescendantOf(Character) and not hit:isDescendantOf(workspace.ignoreModel)) and not isWallIgnored(hit) then
RemoteService.send("Server","FireExplosive",S,item,ViewModel.gunIgnore,hit,P,N,bulletDirection,Ignore,CurrentItem:getFirePort(2))
OBJ.Destroy(bullet)
end
end
end)
end
----------------------------------------------------------------------------------
currentSpread = currentSpread + S.spreadSettings.Increase
--[[
for i = 1,#Libraries.Plugins.Firing do
runAsync(function()
Libraries.Plugins.Firing[i](Player)
end)
end
]]--
local backRecoil = Utils.RAND(S.recoilSettings.Recoil.Back.Min, S.recoilSettings.Recoil.Back.Max, 0.01) --Get the kickback recoil
local upRecoil = Utils.RAND(S.recoilSettings.Recoil.Up.Min, S.recoilSettings.Recoil.Up.Max, 0.01) --Get the up recoil
local sideRecoilAlpha = 0
if CharState.lastSideRecoil[1] < 0 and CharState.lastSideRecoil[2] < 0 then --This conditional basically makes sure the gun tilt isn't in the same direction for more than 2 shots
sideRecoilAlpha = Utils.RAND(0, 1, 0.1)
elseif CharState.lastSideRecoil[1] > 0 and CharState.lastSideRecoil[2] > 0 then
sideRecoilAlpha = Utils.RAND(-1, 0, 0.1)
else
sideRecoilAlpha = Utils.RAND(-1, 1, 0.1)
end
local sideRecoil = Utils.numLerp(S.recoilSettings.Recoil.Side.Left, S.recoilSettings.Recoil.Side.Right, sideRecoilAlpha / 2 + 0.5) --Get the side recoil
local tiltRecoil = Utils.numLerp(S.recoilSettings.Recoil.Tilt.Left, S.recoilSettings.Recoil.Tilt.Right, sideRecoilAlpha / 2 + 0.5) --Get the tilt recoil
local recoilPos = V3(
0,---sideRecoil,
0,
-backRecoil
)
local recoilRot = V3(
0,
RAD(sideRecoil * 10),
RAD(tiltRecoil * 10)
)
local camRecoilRot = V3(
-RAD(sideRecoil * 10),
RAD(upRecoil * 10) * S.recoilSettings.camMultiplier,
0
) * CharState.stanceSway
--Libraries.Haptics.Recoil(1,Player)
tween("Recoil",recoilPos, recoilRot, EasingEasel:getAlpha("Sine@Out"), 0.2)
tween("Cam","Recoil", camRecoilRot, EasingEasel:getAlpha("Sine@Out"), 0.15)
for _, v in pairs(CurrentItem:getFirePort(2):GetChildren()) do
if v.Name:find("FlashFX") then
v.Enabled = true
end
end
RemoteService.send("Server","MuzzleFlash",CurrentItem:getFirePort(2))
delay(0.05, function()
--Libraries.Haptics.Recoil(2,Player)
tween("Recoil",V3(), V3(), EasingEasel:getAlpha("Sine@Out"), 0.2)
tween("Cam","Recoil", V3(), EasingEasel:getAlpha("Sine@Out"), 0.15)
for _, v in pairs(CurrentItem:getFirePort(2):GetChildren()) do
if v.Name:find("FlashFX") then
v.Enabled = false
end
end
end)
firstShot = false
shotCount = shotCount + 1
CharState.lastSideRecoil[(shotCount % 2) + 1] = sideRecoilAlpha
end;
}
local aimedGripCF = function(aimPart)
local handleCF = CharacterParts.Torso.CFrame * CF.RAW(0, 0.5, 0) * armC0[2] * S.aimedC1.rightArm:inverse() * ViewModel.Grips.Right.C0
local handleOffset = CF.TOS(aimPart.CFrame,item.HoldPart.CFrame)
return CF.TOS(((CharacterParts.Torso.CFrame * CF.RAW(CharState:getHeadOffset(S).X, CharState:getHeadOffset(S).Y, 0)) * handleOffset),handleCF)
end;
CurrentItem = setmetatable({
getFirePort = function(self,index)
return Main[index]
end;
createBullet = function(self,Direction,index)
local Origin = self:getFirePort(index).CFrame.p
local bulletCF = CF.RAW(Origin, Origin + Direction)
local Bullet = OBJ("Part")
Bullet.BrickColor = BrickColor.White()
Bullet.Material = Enum.Material.Neon
Bullet.Name = "Bullet"
Bullet.CanCollide = false
Bullet.Size = CurrentCartridge.Size
Bullet.BottomSurface = "Smooth"
Bullet.TopSurface = "Smooth"
local TrailFront = OBJ('Attachment')
TrailFront.Position = V3(0.1, 0, 0)
TrailFront.Parent = Bullet
local TrailBack = OBJ('Attachment')
TrailBack.Position = V3(-0.1, 0, 0)
TrailBack.Parent = Bullet
local Trail = OBJ('Trail')
Trail.Attachment0 = TrailFront
Trail.Attachment1 = TrailBack
Trail.Transparency = NumberSequence.new(0)
Trail.LightEmission = 1
Trail.TextureLength = 0.1
Trail.Lifetime = 0.05
Trail.FaceCamera = true
Trail.Parent = Bullet
Trail.Color = ColorSequence.new(CurrentCartridge.Color.Color)
local BF = OBJ ("VectorForce")
BF.Attachment0 = TrailFront
BF.RelativeTo = Enum.ActuatorRelativeTo.World
BF.Force = V3(0, Bullet:GetMass() * (196.2 - CurrentCartridge.Acceleration), 0)
BF.Parent = Bullet
Bullet.Parent = ViewModel.gunIgnore
Bullet.CFrame = bulletCF + Direction * CurrentCartridge.Size.Z / 2
Bullet.Velocity = Direction * CurrentCartridge.Velocity
RemoteService.send("Server","ReplicateBullet",Direction,Bullet.CFrame,CurrentCartridge.Name)
return Bullet
end;
findBolt = function(self,role)
local result = nil
for _, gunPart in pairs(item:GetChildren()) do
if gunPart:IsA("BasePart") then
if gunPart.Name == "Bolt" then
if gunPart:FindFirstChild("BoltRole") then
if gunPart.BoltRole.Value == role then
result = gunPart
end
end
end
end
end
return result
end;
Damage = function(self,H, P, N, D, Dist, customIgnore)
RemoteService.send("Server","DoDamage",Humanoid, S, H, P, N, D, Dist, customIgnore, CurrentCartridge.Name)
end;
penetrateWall = function(self, Wall, hitPos, Direction, Normal, Ignore, totalPDist, totalBDist, lastDamagedHumanoid)
local wallIgnore = isWallIgnored(Wall)
local hitHumanoid = self:Damage(Wall, hitPos, Normal, Direction, totalBDist, Ignore)
local damagedHumanoid = nil
if hitHumanoid and hitHumanoid ~= lastDamagedHumanoid then
lastDamagedHumanoid = hitHumanoid
damagedHumanoid = self:Damage(Wall, hitPos, Normal, Direction, totalBDist, Ignore)
else
lastDamagedHumanoid = nil
-- DamageVehicle(Wall,totalBDist)
if Wall.Name == "Window" then
--Libraries.Network.send("Server","BreakWindow",Wall, workspace)
end
end
local ignoreObject = hitHumanoid and (Wall.Parent:IsA("Hat") and Wall.Parent.Parent or Wall.Parent) or Wall
Utils.INSERT(Ignore, ignoreObject)
local rayLength = CurrentCartridge:GetPenetrationDepth(Wall.Material)
local testRay = RAY.RAW(hitPos, Direction * CurrentCartridge:GetPenetrationDepth(Wall.Material))
local H1, P1, N1 = RAY.CAST(workspace,testRay, Ignore)
local newIgnore = Utils.removeElement(Ignore, ignoreObject)
local wallRay = RAY.RAW(P1 + Direction * 0.1, -Direction * (rayLength + 1))
local H2, P2, N2 = RAY.CAST(workspace,wallRay, Ignore)
local newPDist = totalPDist + (wallIgnore and 0 or (Utils.getNearestPoint(P1, P2, hitPos) - hitPos).magnitude)
local newBDist = totalBDist + (P1 - hitPos).magnitude
local outOfRange = Utils.Round(newPDist, 0.001) > rayLength or Utils.Round(newBDist, 0.001) > CurrentCartridge.Range
if (not wallIgnore) then
makeHole(Wall, P2, N2, Direction, hitHumanoid, S)
end
if newPDist < CurrentCartridge:getRequiredThickness(Wall,Normal) or outOfRange or (not H1) then
if (not outOfRange) and (not wallIgnore) then
end
if Wall:FindFirstAncestor("Fragmentables") then
RemoteService.send("Server","BreakWindow",Wall)
end
return Wall, hitPos
else
if Wall == H2 and (not wallIgnore) then
end
if Wall:FindFirstAncestor("Fragmentables") then
RemoteService.send("Server","BreakWindow",Wall)
end
PenetrationTries = PenetrationTries - 1
if PenetrationTries ~= 0 then
return self:penetrateWall(H1, P1, Direction, N1, Ignore, newPDist, newBDist, lastDamagedHumanoid)
else
PenetrationTries = S.penetrationSettings.maxTries
return nil
end
end
end;
LoadAnim = function(self,Item)
Animations = require(Item.ANIMATIONS)
end;
playSound = function(self,id, volume, pitch, playbackSpeed)
local Sound = self.Value.HoldPart:FindFirstChild("MainSound")
Sound.SoundId = id
if volume then
Sound.Volume = volume
end
if pitch then
Sound.Pitch = pitch
end
if playbackSpeed then
Sound.PlaybackSpeed = playbackSpeed
end
Sound:Play()
local soundConn
soundConn = Sound.Ended:connect(function()
Sound.SoundId = ""
Sound.Volume = 1
Sound.Pitch = 1
Sound.PlaybackSpeed = 1
soundConn:disconnect()
end)
end;
changeStance = function(self,...)
local args = {...}
if args[1] == "Stand" then
ViewModel.LLegWeld.Part1 = nil
CharacterJoints.Hips.Left.Part1 = CharacterParts.LLeg
ViewModel.RLegWeld.Part1 = nil
CharacterJoints.Hips.Right.Part1 = CharacterParts.RLeg
CharState.Stance = 0
spreadStance = "Stand"
runAsync(function()
local prevStanceSway = stanceSway
local X = 0
local Increment = 1.5 / S.stanceSettings.Speed
while true do
wait(1/60)
local newX = X + Increment
X = (newX > 90 and 90 or newX)
if CharState.Stance ~= 0 then break end
stanceSway = Utils.numLerp(prevStanceSway, 1, EasingEasel:getAlpha("Sine@Out")(X))
if X == 90 then break end
end
end)
tween("Joint",ViewModel.ABWeld, CF.RAW(), nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",ViewModel.LLegWeld, legC0.Stand[1], nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",ViewModel.RLegWeld, legC0.Stand[2], nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",CharacterJoints.Hips.Left, CF.RAW(-1, -1, 0) * CF.ANG(0, RAD(-90), 0), CF.RAW(-0.5, 1, 0) * CF.ANG(0, RAD(-90), 0), EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",CharacterJoints.Hips.Right, CF.RAW(1, -1, 0) * CF.ANG(RAD(-180), RAD(90), 0), CF.RAW(0.5, 1, 0) * CF.ANG(RAD(-180), RAD(90), 0), EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",CharacterJoints.Root, CF.ANG(RAD(-90), 0, RAD(180)), nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",ViewModel.headWeld, CF.RAW(0, 1.5, 0), nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
elseif args[1] == "Crouch" then
ViewModel.LLegWeld.Part1 = CharacterParts.LLeg
CharacterJoints.Hips.Left.Part1 = nil
ViewModel.RLegWeld.Part1 = CharacterParts.RLeg
CharacterJoints.Hips.Right.Part1 = nil
CharState.Stance = 1
spreadStance = "Crouch"
runAsync(function()
local prevStanceSway = stanceSway
local X = 0
local Increment = 1.5 / S.stanceSettings.Speed
while true do
wait(1/60)
local newX = X + Increment
X = (newX > 90 and 90 or newX)
if CharState.Stance ~= 0 then break end
stanceSway = Utils.numLerp(prevStanceSway, 0.75, EasingEasel:getAlpha("Sine@Out")(X))
if X == 90 then break end
end
end)
tween("Joint",ViewModel.ABWeld, CF.RAW(0, 0, -0.05), nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",ViewModel.LLegWeld, legC0.Crouch[1], nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",ViewModel.RLegWeld, legC0.Crouch[2], nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",CharacterJoints.Hips.Left, CF.RAW(-1, -0.5, 0) * CF.ANG(0, RAD(-90), 0), CF.RAW(-0.5, 0.5, 1) * CF.ANG(0, RAD(-90), RAD(-90)), EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",CharacterJoints.Hips.Right, CF.RAW(1, -0.5, 0.25) * CF.ANG(RAD(-180), RAD(90), 0), CF.RAW(0.5, 0.5, 1) * CF.ANG(RAD(-180), RAD(90), 0), EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",CharacterJoints.Root, CF.RAW(0, -1, 0) * CF.ANG(RAD(-90), 0, RAD(180)), nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",ViewModel.headWeld, CF.RAW(0, 1.5, 0), nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
elseif args[1] == "Prone" then
ViewModel.LLegWeld.Part1 = CharacterParts.LLeg
CharacterJoints.Hips.Left.Part1 = nil
ViewModel.RLegWeld.Part1 = CharacterParts.RLeg
CharacterJoints.Hips.Right.Part1 = nil
CharState.Stance = 2
spreadStance = "Prone"
runAsync(function()
local prevStanceSway = stanceSway
local X = 0
local Increment = 1.5 / S.stanceSettings.Speed
while true do
wait(1/60)
local newX = X + Increment
X = (newX > 90 and 90 or newX)
if CharState.Stance ~= 0 then break end
stanceSway = Utils.numLerp(prevStanceSway, 0.5, EasingEasel:getAlpha("Sine@Out")(X))
if X == 90 then break end
end
end)
tween("Joint",ViewModel.ABWeld, CF.RAW(0, 0, -0.1), nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",ViewModel.LLegWeld, legC0.Prone[1], nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",ViewModel.RLegWeld, legC0.Prone[2], nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",CharacterJoints.Root, CF.RAW(0, -2.5, 1) * CF.ANG(RAD(180), 0, RAD(180)), nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
tween("Joint",ViewModel.headWeld, CF.RAW(0, 1, 1) * CF.ANG(RAD(90), 0, 0), nil, EasingEasel:getAlpha("Sine@Out"), S.stanceSettings.Speed)
elseif args[1] == "Dive" then
CharState.grounded = false
local diveDirection = (CharacterParts.HRP.CFrame * CF.ANG(S.diveSettings.Angle, 0, 0)).lookVector * Humanoid.WalkSpeed * S.diveSettings.Force
spawn(function()
CharacterParts.HRP.Velocity=CharacterParts.HRP.CFrame.lookVector*60+V3(0,40,0)
wait(.1)
CharacterParts.HRP.Velocity=CharacterParts.HRP.CFrame.lookVector*70+V3(0,30,0)
wait(.4)
CharacterParts.HRP.Velocity=CharacterParts.HRP.CFrame.lookVector*30+V3(0,-10,0)
end)
runAsync(function()
while true do
local newRay = RAY.RAW(CharacterParts.HRP.Position, V3(0, -3.1, 0))
local H, _ = RAY.CAST(workspace,newRay, Ignore)
if H then
CharState.grounded = true
break
end
wait()
end
end)
self:changeStance("Prone")
wait(0.1)
end
HudController:changeStanceImage(CharState.Stance)
end;
lowerSpread = function(self)
if (not loweringSpread) then
loweringSpread = true
local Connection = nil
Connection = RunService.Heartbeat:connect(function(dt)
if InputComp:IsActive() and Firing then
Connection:disconnect()
end
local newSpread = currentSpread - (S.spreadSettings.Decrease * dt)
currentSpread = (newSpread < 0 and 0 or newSpread)
if currentSpread == 0 then
Connection:disconnect()
end
end)
loweringSpread = false
end
end;
PlayAnimation = function(self,animName,...)
tween("Joint",ViewModel.LWeld2, CF.RAW(), CF.RAW(), EasingEasel:getAlpha("Sine@Out"), 0.15)
tween("Joint",ViewModel.RWeld2, CF.RAW(), CF.RAW(), EasingEasel:getAlpha("Sine@Out"), 0.15)
local selfObj = self
local magParts = {}
for _, Obj in pairs(item:GetChildren()) do
if Obj.Name:sub( 1, 3) == "Mag" and Obj:IsA("BasePart") then
Utils.INSERT(magParts, Obj)
end
end
local api = {
isMagVisible = function()
return magVisible
end;
isMagEmpty = function()
return ammoInClip == 0
end;
tweenJoint = function(Joint,newC0,newC1,Alpha,Duration)
tween("Joint",Joint,newC0,newC1,Alpha,Duration)
end;
tweenRecoil = function(Pos, Rot, Alpha, Duration)
tween("Recoil" , Pos, Rot, Alpha, Duration)
end;
getAlpha = function(alphaToken)
return EasingEasel:getAlpha(alphaToken)
end;
tweenBolt = function(Key, Kick, Rot, Alpha, Duration)
tween("Bolt", Key, Kick, Rot, Alpha, Duration)
end;
attachGripToArm = function(armType)
if armType == "Left" then
ViewModel.Grips.Left.Part0 = CharacterParts.LArm
local HandleCF = item.HoldPart.CFrame
ViewModel.Grips.Left.Part1 = item.HoldPart
ViewModel.Grips.Right.Part0 = nil
ViewModel.Grips.Left.C0 = CharacterParts.LArm.CFrame:toObjectSpace(HandleCF)
ViewModel.Grips.Current = "Left"
else
ViewModel.Grips.Left.Part0 = nil
ViewModel.Grips.Right.Part0 = CharacterParts.RArm
ViewModel.Grips.Right.Part1 = item.HoldPart
ViewModel.Grips.Current = "Right"
end
end;
FRArm = ViewModel.fakeRArm;
FLArm = ViewModel.fakeLArm;
waitForInputRelease = function()
if Type == "Grenade" then
repeat wait() until not InputComp:IsInputDown(Enum.UserInputType.MouseButton1)
end
end;
setNadeCFrame = function(key, nadeCF)
local nade = ((grenadeTable[key]:IsA("BasePart")) and grenadeTable[key] or grenadeTable[key]:WaitForChild("Center",200))
nade.CFrame = nadeCF
end;
createGrenade = function(Name,weldNade)
local nade
local Grenade
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild(S.nadeType)
if not Grenade then return end
Grenade = Grenade:Clone()
Grenade:SetPrimaryPartCFrame(CharacterParts.RArm.CFrame)
for _, part in pairs(Grenade:GetChildren()) do
if part:IsA("BasePart") and part ~= Grenade.Center then
local w = Instance.new("Weld")
w.Part0 = Grenade.Center
w.Part1 = part
w.C0 = Grenade.Center.CFrame:toObjectSpace(part.CFrame)
w.C1 = CF.RAW()
w.Parent = w.Part0
part.Anchored = false
end
end
if weldNade then
local Weld = Instance.new("Motor6D")
Weld.Part0 = CharacterParts.RArm
Weld.Part1 = Grenade:WaitForChild("Center")
Weld.C0 = ViewModel.Grips.Right.C0
Weld.Parent = Grenade:WaitForChild("Center")
end
Grenade.Center.Anchored = false
Grenade.Parent = workspace.ignoreModel.grenadeFolder
nade = Grenade
grenadeTable[Name] = nade
return nade, Name
end;
getNade = function(name)
return grenadeTable[name]
end;
destroyNade = function(key)
local nade = grenadeTable[key]
nade:Destroy()
grenadeTable[key] = nil
end;
addNadeVelocity = function(key, vel)
local nade = (( grenadeTable[key]:IsA("BasePart")) and grenadeTable[key] or grenadeTable[key]:WaitForChild("Center",200))
nade.Velocity = nade.Velocity + vel
end;
divideNadeVelocity = function(key, vel)
local nade = (( grenadeTable[key]:IsA("BasePart")) and grenadeTable[key] or grenadeTable[key]:WaitForChild("Center",200))
nade.Velocity = nade.Velocity / vel
end;
setNadeRotVelocity = function(key, vel)
local nade = (( grenadeTable[key]:IsA("BasePart")) and grenadeTable[key] or grenadeTable[key]:WaitForChild("Center",200))
nade.RotVelocity = vel
end;
mainCF = function(Main)
return Main.Center.CFrame
end;
headCF = function()
return CharacterParts.Head.CFrame
end;
playNadeSound = function(sound,Parent)
local Sound = Instance.new("Sound")
Sound.SoundId = sound
Sound.Volume = 1
Sound.Parent = Parent
end;
getGrenadeType = function()
return S.grenadeMetaType
end;
nadeIsA = function(nadeType)
return CurrentItem.Settings.nadeType == nadeType;
end;
Detonate = function(bt,...)
RemoteService.send("Server","DetonateNade",bt,...)
end;
isIgnored = function(Obj)
return isWallIgnored(Obj, Ignore)
end;
stick = function(gCF,key,Obj)
local nade = grenadeTable[key]
--Libraries.Network.send("Server","StickNade",nade,Obj,gCF)
end;
hideCurrentNade = function()
for _, obj in pairs(item:GetChildren()) do
if obj:IsA("BasePart") then
obj.Transparency = 1
obj.CanCollide = false
end
end
end;
setNewMag = function()
newMag = true
end;
isNewMag = function()
return newMag
end;
preloadAmmoUI = function()
end;
createMag = function(Key,transparent)
local magModel = OBJ("Model")
local magClones = {}
local magRevolverCase = nil;
for i, v in pairs(magParts) do
local vClone =v:Clone()
vClone.Transparency = (transparent and 1 or v:WaitForChild("magTrans").Value)
for _, v2 in pairs(vClone:GetChildren()) do
if v2:IsA("Texture") then
v2.Transparency = 0
end
end
if S.isRevolver and vClone.Name == "MagCase" then
magRevolverCase = vClone
if not magCaseVisible then
vClone.Transparency = 1
end
end
vClone.CanCollide = false
vClone.Parent = magModel
if vClone ~= magRevolverCase then
Utils.INSERT(magClones, {Original = v, magClone = vClone})
for _, joint in pairs(vClone:GetChildren()) do
if joint:IsA("JointInstance") then
joint:Destroy()
end
end
if i ~= 1 then
if not S.isRevolver then
local W = OBJ("Motor6D")
W.Part0 = magClones[1].magClone
W.Part1 = vClone
W.C0 = CF.TOS(magClones[1].magClone.CFrame,vClone.CFrame)
W.Parent = magClones[1].magClone
else
if not magRevolverCase then return end
local W = OBJ("Motor6D")
W.Part0 = magRevolverCase
W.Part1 = vClone
W.C0 = CF.TOS(magRevolverCase.CFrame,vClone.CFrame)
W.Parent = magRevolverCase
end
end
end
if S.LMGSettings.magIsBolt then
local magBolt = selfObj:findBolt("Main");
if magBolt then
local boltClone = magBolt:Clone()
for _, joint in pairs(boltClone:GetChildren()) do
if joint:IsA("JointInstance") then
joint:Destroy()
end
end
local boltWeld2 = OBJ("Motor6D")
boltWeld2.Part0 = magClones[1].magClone
boltWeld2.Part1 = boltClone
boltWeld2.C0 = CF.TOS(magClones[1].magClone.CFrame,boltClone.CFrame)
boltWeld2.Parent = magClones[1].magClone
for _, part in pairs(item:GetChildren()) do
if part:IsA("BasePart") then
if part.Name == "BoltPart" then
if part:FindFirstChild("BoltRole") then
if part.BoltRole.Value == "Main" then
local boltPartClone = part:Clone()
boltPartClone:BreakJoints()
for _, joint in pairs(boltPartClone:GetChildren()) do
if joint:IsA("JointInstance") then
joint:Destroy()
end
end
local boltPartWeld = OBJ("Motor6D")
boltPartWeld.Part0 = boltClone
boltPartWeld.Part1 = boltPartClone
boltPartWeld.C0 = CF.TOS(boltClone.CFrame,boltPartClone.CFrame)
boltPartWeld.Parent = boltClone
boltPartClone.Parent = magModel
end
end
end
end
end
boltClone.Parent = magModel
end
end
end
magTable[Key] = {magModel, magClones}
if magRevolverCase then
Utils.INSERT(magTable[Key],magRevolverCase)
end
return magModel, magClones, magRevolverCase
end;
makeMagInvisible = function()
for _, v in pairs(magParts) do
v.Transparency = 1
for _, v2 in pairs(v:GetChildren()) do
if v2:IsA("Texture") then
v2.Transparency = 1
end
end
end
if S.LMGSettings.magIsBolt then
local magBolt = selfObj:findBolt("Main");
if magBolt then
magBolt.Transparency = 1;
for _, part in pairs(item:GetChildren()) do
if part:IsA("BasePart") then
if part.Name == "BoltPart" then
if part:FindFirstChild("BoltRole") then
if part.BoltRole.Value == "Main" then
part.Transparency = 1;
end
end
end
end
end
end
end
magVisible = false
end;
getMagInsertionCFrame = function(LC1,RC1,GC1,magClones)
local ArmBase = ViewModel.armBase
local LArmCF, RArmCF, handleOffsetCF, originalMagOffsetCF = CF.RAW(),CF.RAW(),CF.RAW(),CF.RAW()
local newMagCF = CF.RAW()
if LC1 then
LArmCF = ArmBase.CFrame *ViewModel.LWeld.C0 *(LC1):inverse()
end
if RC1 then
RArmCF = ArmBase.CFrame * ViewModel.RWeld.C0 * (RC1):inverse()
end
if GC1 then
local gripArm = currentGripArm()
handleOffsetCF = gripArm.CFrame:toObjectSpace(gripArm.CFrame * ViewModel.Grips.Right.C0 *(GC1):inverse())
end
if magClones then
originalMagOffsetCF = item.HoldPart.CFrame:toObjectSpace(magClones[1].Original.CFrame)
end
local gArm = currentGripArm()
if gArm == CharacterParts.RArm then
newMagCF = LArmCF:toObjectSpace(RArmCF * handleOffsetCF * originalMagOffsetCF)
elseif gArm == CharacterParts.LArm then
newMagCF = RArmCF:toObjectSpace(LArmCF * handleOffsetCF * originalMagOffsetCF)
end
return newMagCF
end;
repeatUntilReloaded = function(repetition)
for i = Ammo.Value, Ammo.Value <= ClipSize.Value and (ClipSize.Value + 1) or ClipSize.Value do
repetition()
Ammo.Value =i
HudController:updateAmmo(Ammo.Value,ClipSize.Value,StoredAmmo.Value);
end
end;
startingLC1 = function()
return Aimed and S.aimedC1.leftArm or S.unAimedC1.leftArm
end;
LidHinge = function()
if S.isLMG then
return item.LidEffector:FindFirstChild("LidHinge");
end
return nil
end;
makeMagVisible = function()
for _, v in pairs(magParts) do
v.Transparency = v:WaitForChild("magTrans").Value
for _, v2 in pairs(v:GetChildren()) do
if v2:IsA("Texture") then
v2.Transparency = 0
end
end
end
if S.LMGSettings.magIsBolt then
local magBolt = selfObj:findBolt("Main");
if magBolt then
magBolt.Transparency = 0;
for _, part in pairs(item:GetChildren()) do
if part:IsA("BasePart") then
if part.Name == "BoltPart" then
if part:FindFirstChild("BoltRole") then
if part.BoltRole.Value == "Main" then
part.Transparency = 0;
end
end
end
end
end
end
end
magVisible = true
end;
playSound = function(...)
selfObj:playSound(...)
end;
getMag = function(Key)
if magTable[Key] then
return magTable[Key][1], magTable[Key][2], magTable[Key][3]
else
return nil, nil, nil
end
end;
Handle = item.HoldPart;
LArm = CharacterParts.LArm;
RArm = CharacterParts.RArm;
Torso = CharacterParts.Torso;
LWeld = ViewModel.LWeld;
RWeld = ViewModel.RWeld;
LWeld2 = ViewModel.LWeld2;
RWeld2 = ViewModel.RWeld2;
LC0 = armC0[1];
RC0 = armC0[2];
LC1U = S.unAimedC1.leftArm;
RC1U = S.unAimedC1.rightArm;
iGripC1 = S.unAimedC1.Grip;
LGrip = ViewModel.Grips.Left;
RGrip = ViewModel.Grips.Right;
Grip = ViewModel.Grips[ViewModel.Grips.Current];
gunIgnore = ViewModel.gunIgnore;
Cam = CameraService.Cam;
CF = CF.RAW;
CFANG = CF.ANG;
V3 = V3;
RAD = RAD;
Player = player;
throwVelocity = S.grenadeSettings.Lethal.throwVelocity;
timerStartOnHit = S.grenadeSettings.detonationSettings.StartOnHit;
detonationTime = S.grenadeSettings.detonationSettings.Time;
lethalGrenadeDamage = S.grenadeSettings.Lethal.damage;
allowFriendlyFire = S.AllowFriendlyFire;
CanDamageNPCs = S.CanDamageNPCs;
ShockwaveColor = S.shockwaveSettings.Color;
explosionType = S.grenadeSettings.Type;
blastRadius = S.grenadeSettings.Radius;
blastPressure = S.grenadeSettings.Pressure;
ShockwaveDuration = S.shockwaveSettings.Duration;
grenadeEffectRadius = S.grenadeSettings.detonationSettings.effectRadius;
grenadeEffectTime = S.grenadeSettings.detonationSettings.effectTime;
reloadTimeLoaded = S.reloadSettings.Times.Loaded;
reloadTimeEmpty = S.reloadSettings.Times.Empty;
};
local sequenceTable = Animations[animName](api)
--local T = TICK()
for i, animFunction in pairs(sequenceTable) do
if self.breakReload and animName == "Reload" then
break
end
local t0 = tick()
animFunction()
print(tick() - t0)
if (not self.magVisible) and animName == "Reload" then
if self.Ammo then
self.Ammo.Value = 0
end
end
end
if not animName:find("Climbing") then
if (CharState.currentState ~= "Crawling") then
if (CharState.currentState == "Running") and (not CurrentItem.Settings.canFireWhileRunning) and Type == "Gun" then
tween("Joint",ViewModel.LWeld, armC0[1], CurrentItem.Settings.runningC1.leftArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.RWeld, armC0[2], CurrentItem.Settings.runningC1.rightArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.Grips.Right, nil, CurrentItem.Settings.runningC1.Grip, EasingEasel:getAlpha("Sine@Out"), 0.4)
else
if Type == "Gun" then
tween("Joint",ViewModel.LWeld, armC0[1], CurrentItem.Settings.unAimedC1.leftArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.RWeld, armC0[2], CurrentItem.Settings.unAimedC1.rightArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.Grips.Right, nil, CurrentItem.Settings.unAimedC1.Grip, EasingEasel:getAlpha("Sine@Out"), 0.4)
elseif Type == "Grenade" then
tween("Joint",ViewModel.LWeld, armC0[1], CurrentItem.Settings.regularC1.leftArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.RWeld, armC0[2], CurrentItem.Settings.regularC1.rightArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.Grips.Right, nil, CurrentItem.Settings.regularC1.Grip, EasingEasel:getAlpha("Sine@Out"), 0.4)
end
end
end
end
tween("Recoil",V3(),V3(),EasingEasel:getAlpha("Sine@Out"),0.4)
delay(0.4,function()
if ViewModel.Grips.Current == "Left" then
api.attachGripToArm("Right")
end
end)
for _, v in pairs(self.magTable) do --In case the reload animations was stopped mid way and there were still fake mags that weren't deleted
v[1]:Destroy()
end
delay(4,function()
for _, v in pairs(self.grenadeTable) do
v:Destroy()
end
end)
end;
aimGun = function(self)
if Type ~= "Gun" and Type ~= "Explosive" then return end
if CharState.currentState == "Crawling" or (not S.canADS) then print("AimProblem") return end
InputComp.Sensitivity.mouse = InputComp.Sensitivity.aim
--[[
for i = 1,#Libraries.Plugins.Aimed do
runAsync(function()
Libraries.Plugins.Aimed[i](Player)
end)
end
--]]
endRun()
if CharState.currentState ~= "Crawling" then
CharState.currentState = "Idling"
end
Aimed = true
Aiming = true
print("Aim")
spreadZoom = "Aimed"
tween("Joint",ViewModel.LWeld, armC0[1], S.aimedC1.leftArm, EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Joint",ViewModel.RWeld, armC0[2], S.aimedC1.rightArm, EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Joint",ViewModel.LWeld2, nil, CF.RAW(), EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Joint",ViewModel.RWeld2, nil, CF.RAW(), EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Joint",ViewModel.Grips.Right, nil, aimedGripCF(AimPart), EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Joint",ViewModel.headWeld2, nil, CF.RAW(0, -0.5, 0) * CF.ANG(0, 0, S.aimSettings.headTilt) * CF.RAW(0, 0.5, 0), EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Aim",self.Value.FOV.Value,S.aimSettings.Speed,EasingEasel:getAlpha("Sine@Out"))
Aiming = (not Aimed)
--[[if (not Aiming) and Gun.BlackScope.Value then
if Gun.NightVision.Value then
NVEffect = Instance.new("ColorCorrectionEffect")
NVEffect.Brightness = 0.8
NVEffect.Enabled = true
NVEffect.TintColor = Color3.fromRGB(95,255,37)
NVEffect.Saturation = -1
NVEffect.Contrast = 1
NVEffect.Parent = Interface.Cam
NVB = Instance.new("BlurEffect")
NVB.Size = 4
NVB.Parent = Interface.Cam
local OriginalShading = {}
local OriginalShadingAccessories = {}
Services.RS:BindToRenderStep("RenderNightVision",Enum.RenderPriority.Camera.Value,function(dt)
local mobs
local players
if workspace:FindFirstChild("Mobs") then
mobs = workspace.Mobs:GetChildren()
end
players = game.Players:GetPlayers()
if players then
for _, player in pairs(players) do
local mob = player.Character
if mob then
local hum = mob:FindFirstChild("Humanoid")
if hum then
if isEnemy(hum) then
if not OriginalShadingAccessories[mob] then
OriginalShadingAccessories[mob] = {
Shirt = mob:FindFirstChild("Shirt");
Pants = mob:FindFirstChild("Pants");
};
OriginalShadingAccessories[mob].Pants.Parent = game.ReplicatedStorage.ClothesTemp;
OriginalShadingAccessories[mob].Shirt.Parent = game.ReplicatedStorage.ClothesTemp;
end
for _, part in pairs(mob:GetChildren()) do
if part:IsA("BasePart") then
if not OriginalShading[part] then
OriginalShading[part] = {
Material = part.Material;
Color = part.Color;
};
part.Material = Enum.Material.Neon
part.Color = BrickColor.White().Color
end
elseif part:IsA("Model") then
for _, part in pairs(part:GetChildren()) do
if part:IsA("BasePart") then
if not OriginalShading[part] then
OriginalShading[part] = {
Material = part.Material;
Color = part.Color;
};
part.Material = Enum.Material.Neon
part.Color = BrickColor.White().Color
end
end
end
elseif part:IsA("Tool") then
for _, part in pairs(part:GetChildren()) do
if part:IsA("BasePart") then
if not OriginalShading[part] then
OriginalShading[part] = {
Material = part.Material;
Color = part.Color;
};
part.Material = Enum.Material.Neon
part.Color = BrickColor.White().Color
end
end
end
end
end
end
end
end
end
end
if mobs then
for _, mob in pairs(mobs) do
local hum = mob:FindFirstChild("Human")
if hum then
if isEnemy(hum) then
if not OriginalShadingAccessories[mob] then
OriginalShadingAccessories[mob] = {
Shirt = mob:FindFirstChild("Shirt");
Pants = mob:FindFirstChild("Pants");
};
OriginalShadingAccessories[mob].Pants.Parent = game.ReplicatedStorage.ClothesTemp;
OriginalShadingAccessories[mob].Shirt.Parent = game.ReplicatedStorage.ClothesTemp;
end
for _, part in pairs(mob:GetChildren()) do
if part:IsA("BasePart") then
if not OriginalShading[part] then
OriginalShading[part] = {
Material = part.Material;
Color = part.Color;
};
part.Material = Enum.Material.Neon
part.Color = BrickColor.White().Color
end
elseif part:IsA("Model") then
for _, part in pairs(part:GetChildren()) do
if part:IsA("BasePart") then
if not OriginalShading[part] then
OriginalShading[part] = {
Material = part.Material;
Color = part.Color;
};
part.Material = Enum.Material.Neon
part.Color = BrickColor.White().Color
end
end
end
elseif part:IsA("Tool") then
for _, part in pairs(part:GetChildren()) do
if part:IsA("BasePart") then
if not OriginalShading[part] then
OriginalShading[part] = {
Material = part.Material;
Color = part.Color;
};
part.Material = Enum.Material.Neon
part.Color = BrickColor.White().Color
end
end
end
end
end
end
end
end
end
end)
spawn(function()
repeat wait() until not Aimed
for part, props in pairs(OriginalShading) do
if part then
part.Material = props.Material
part.Color = props.Color
end
end
for mob, props in pairs(OriginalShadingAccessories) do
if mob then
props.Shirt.Parent = mob
props.Pants.Parent = mob
end
end
OriginalShadingAccessories = {}
OriginalShading = {}
Services.RS:UnbindFromRenderStep("RenderNightVision")
end)
end
runAsync(function()
scopeSteady.Visible = true
Interface.HUD.Visible = false
Interface.Scope.BackgroundTransparency = 1
scopeMain.Visible = true
if armModel then
for _, Obj in PAIRS(armModel:GetChildren()) do
if Obj:IsA("BasePart") then
Obj.LocalTransparencyModifier = 1
end
end
end
for _, Obj in PAIRS(playerFolder:GetChildren()) do
if Obj:IsA("BasePart") then
Obj.LocalTransparencyModifier = 1
end
end
for _, Obj in PAIRS(Gun:GetChildren()) do
if Obj:IsA("BasePart") then
Obj.LocalTransparencyModifier = 1
if FFC(Obj,"Texture") then
for _, Tex in pairs(Obj:GetChildren()) do
if Tex:IsA("Texture") then
Tex.Transparency = 1
end
end
end
end
end
end)
runAsync(function()
local camAng = 0
local idleCam = function()
return V3.RAW(
RAD(SIN(camAng * S.scopeSettings.Frequency.Idling)) * stanceSway * camSway * S.scopeSettings.Amplitude.Idling,
RAD(SIN(camAng * 2.5 * S.scopeSettings.Frequency.Idling)) * stanceSway * camSway * S.scopeSettings.Amplitude.Idling * 0.75,
0
)
end
local walkCam = function()
return V3.RAW(
RAD(SIN(camAng * S.scopeSettings.Frequency.Walking)) * camSway * stanceSway * S.scopeSettings.Amplitude.Walking,
RAD(SIN(camAng * 2.5 * S.scopeSettings.Frequency.Walking)) * camSway * stanceSway * S.scopeSettings.Amplitude.Walking * 0.75,
0
)
end
while Aimed do
local dt = shortWait(Services.RS.RenderStepped)
camOffsets.guiScope.Rot = (EasingEasel:getAlpha("Sine@Out")(idleAlpha) * idleCam()) + (EasingEasel:getAlpha("Sine@Out")(walkAlpha) * walkCam())
camAng = camAng + RAD(105 * dt) * stanceSway * camSway
end
end)
end
]]--
end;
Reload = function(self)
if Ammo.Value < (ClipSize.Value + 1) and (not Reloading) and StoredAmmo.Value > 0 then
Firing = false
ammoInClip = (ammoInClip == 0 and Ammo.Value or ammoInClip)
Reloading = true
self:lowerSpread()
if Aimed then self:unAimGun(S.reloadSettings.Anim) end
runAsync(function()
end)
if S.reloadSettings.Anim then
wait()
self:PlayAnimation("Reload")
HudController:updateAmmo(Ammo.Value,ClipSize.Value,StoredAmmo.Value)
else
local startReload = tick()
local initialReloadTime = Ammo.Value == 0 and S.reloadSettings.Times.Empty or S.reloadSettings.Times.Loaded
while true do
if self.breakReload then break end
if (tick() - startReload) >= initialReloadTime then break end
wait(1/60)
end
end
if (not breakReload) then
newMag = false
if StoredAmmo.Value >= ClipSize.Value then
if ammoInClip > 0 and not S.isRevolver then
StoredAmmo.Value = StoredAmmo.Value - ((ClipSize.Value + 1) - ammoInClip)
Ammo.Value = ClipSize.Value + 1
else
StoredAmmo.Value = StoredAmmo.Value - ClipSize.Value
Ammo.Value = ClipSize.Value
end
elseif StoredAmmo.Value < ClipSize.Value and StoredAmmo.Value > 0 then
Ammo.Value = StoredAmmo.Value
StoredAmmo.Value = 0
end
end
Reloading = false
if self.Equipped then
ammoInClip = (breakReload and ammoInClip or 0)
end
breakReload = false
end
HudController:updateAmmo(Ammo.Value,ClipSize.Value,StoredAmmo.Value)
end;
unAimGun = function(self,Exception)
if (not S.canADS) then return end
InputComp.Sensitivity.mouse = RemoteService.fetch("Server","GetSensitivity","Gun")
--[[
for _, Plugin in pairs(Libraries.Plugins.UnAimed) do
runAsync(function()
Plugin()
end)
end
]]--
--[[
if item.BlackScope.Value then
if NVEffect then
NVEffect:Destroy()
NVB:Destroy()
end
runAsync(function()
if armModel then
for _, Obj in PAIRS(armModel:GetChildren()) do
if Obj:IsA("BasePart") then
Obj.LocalTransparencyModifier = 0
end
end
end
for _, Obj in PAIRS(playerFolder:GetChildren()) do
if Obj:IsA("BasePart") then
Obj.LocalTransparencyModifier = 0
end
end
for _, Obj in PAIRS(Gun:GetChildren()) do
if Obj:IsA("BasePart") then
Obj.LocalTransparencyModifier = 0
if FFC(Obj,"Texture") then
for _, Tex in pairs(Obj:GetChildren()) do
if Tex:IsA("Texture") then
Tex.Transparency = 0
end
end
end
end
end
end)
end
]]--
ViewModel.fakeLArm.LocalTransparencyModifier = 0
ViewModel.fakeRArm.LocalTransparencyModifier = 0
if (not Exception) then
if (not Aimed) then return end
if (Exception) then return end
spreadZoom = "unAimed"
Aimed = false
Aiming = true
local currentFOV = CameraService.Cam.FieldOfView
HudController:hideScope()
tween("Joint",ViewModel.LWeld, armC0[1], S.unAimedC1.leftArm, EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Joint",ViewModel.RWeld, armC0[2], S.unAimedC1.rightArm, EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Joint",ViewModel.headWeld2, nil, CF.RAW(), EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Joint",ViewModel.Grips.Right, nil, S.unAimedC1.Grip, EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Aim",S.aimSettings.OutFOV,S.aimSettings.Speed,EasingEasel:getAlpha("Sine@Out"))
HudController.UI.HUD.Visible = true
Aiming = Aimed
else
runAsync(function()
Aimed = false
Aiming = false
spreadZoom = "unAimed"
local currentFOV = CameraService.Cam.FieldOfView
HudController:hideScope()
tween("Joint",ViewModel.headWeld2, nil, CF.RAW(), EasingEasel:getAlpha("Sine@Out"), S.aimSettings.Speed)
tween("Aim",S.aimSettings.OutFOV,S.aimSettings.Speed,EasingEasel:getAlpha("Quad@Out"))
end)
end
end;
},{
__index = function(self,k)
local key = k:lower()
if key == "settings" then
return S
elseif key == "value" then
return item
elseif key == "type" then
return Type
elseif key == "breakReload" then
return breakReload
elseif key == "magVisible" then
return magVisible
elseif key == "animations" then
return Animations
elseif key == "grenadetable" then
return grenadeTable
elseif key == "magtable" then
return magTable
elseif key == "firingsystem" then
return FiringSystem
elseif key == "main" then
return Main
elseif key == "slidepart" then
return SlidePart
elseif key == "canselectfire" then
return canSelectFire
elseif key == "equipped" then
return Equipped
elseif key == "aimed" then
return Aimed
elseif key == "basespread" then
return S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
elseif key == "currentspread" then
return currentSpread
elseif key == "crossoffset" then
return crossOffset
elseif key == "firingapi" then
local obj = self
return {
currentFireMode = function()
return FiringSystem.currentMode.Name;
end;
setCanFire = function(bool)
canFire = bool
end;
getCanFire = function()
return canFire
end;
setFiring = function(bool)
Firing = bool
end;
isCrawling = function()
return CharState.currentState == "Crawling"
end;
Reloading = function()
return Reloading;
end;
MB1Down = function()
print(InputComp:IsActive())
return InputComp:IsActive();
end;
Ammo = Ammo;
Lethals = item.LethalGrenades;
Click = function()
if Ammo.Value <= 0 then
obj:playSound("rbxassetid://131242822")
end
end;
Humanoid = Humanoid;
useAmmo = function()
Ammo.Value = Ammo.Value - 1;
HudController:updateAmmo(Ammo.Value,ClipSize.Value,StoredAmmo.Value)
end;
useLethal = function()
item.LethalGrenades.Value = item.LethalGrenades.Value - 1
-- updateGUI("Grenades")
end;
unSteadyCam = function()
if Aimed and S.scopeSettings.unSteadyOnFire then
-- steadyKeyPressed = false
-- currentSteadyTime = 0
end
end;
setNewMag = function(bool)
newMag = bool
end;
fireGun = function()
projectileTypes.Gun();
end;
fireGrenade = function()
projectileTypes.Grenade()
end;
fireMag = function()
if S.reloadSettings.magIsBullet then
for _, Mag in pairs(item:GetChildren()) do
if Mag.Name:sub(1, 3) == "Mag" then
Mag.Transparency = 1
end
end
end
end;
ReloadWhenEmpty = function()
if Ammo.Value == 0 and S.reloadSettings.autoReload then
wait(0.2)
self:Reload()
end
end;
yieldFireRate = function()
wait(60 / S.roundsPerMin)
end;
getFireRate = function()
return 60 / S.roundsPerMin
end;
doBurst = function(action,burstTime)
for i = 1, S.burstSettings.Amount do
action()
if Ammo.Value == 0 and S.reloadSettings.autoReload then
wait(0.2)
self:Reload()
break
end
wait(S.burstSettings.fireRateBurst and burstTime or S.burstSettings.Time / S.burstSettings.Amount)
end
end;
yieldBurstFireRate = function(burstTime)
wait(S.burstSettings.fireRateBurst and burstTime or S.burstSettings.Wait)
end
}
else
end
end;
__newindex = function(self,k,v)
local key = k:lower()
if key == "value" then
item = v
if item then
AimPart = item:FindFirstChild("AimPart")
Ammo = item:FindFirstChild("Ammo")
ClipSize = item:FindFirstChild("ClipSize")
StoredAmmo = item:FindFirstChild("StoredAmmo")
HudController:updateAmmo(Ammo.Value,ClipSize.Value,StoredAmmo.Value)
end
elseif key == "settings" then
S = v
crossSpring = Utils.CreateGameObject("Spring","Number",S.spreadSettings[spreadZoom][spreadStance][spreadMotion])
crossSpring.s = 12
crossSpring.d = 0.65
if Type == "Gun" then
CurrentCartridge = Cartridges[S.bulletSettings.Cartridge]
if CurrentCartridge then
if S.bulletSettings.RangeModifier then
CurrentCartridge.Range = CurrentCartridge.Range + S.bulletSettings.RangeModifier
end
if S.bulletSettings.VelocityModifier then
CurrentCartridge.Velocity = CurrentCartridge.Velocity + S.bulletSettings.VelocityModifier
end
if S.bulletSettings.AccelerationModifier then
CurrentCartridge.Acceleration = CurrentCartridge.Acceleration + S.bulletSettings.AccelerationModifier
end
if S.bulletSettings.SizeOverride then
CurrentCartridge.Size = S.bulletSettings.SizeOverride
end
if S.bulletSettings.ColorOverride then
CurrentCartridge.ColorOverride = S.bulletSettings.ColorOverride
end
CurrentCartridge:CalibrateSize()
HudController:updateCartridge(CurrentCartridge)
end
end
elseif key == "type" then
Type = v
elseif key == "firingsystem" then
FiringSystem = v
elseif key == "slidepart" then
SlidePart = v
elseif key == "main" then
Main = v
elseif key == "canselectfire" then
canSelectFire = v
elseif key == "equipped" then
Equipped = v
elseif key == "spreadzoom" then
spreadZoom = v
elseif key == "spreadstance" then
spreadStance = v
elseif key == "spreadmotion" then
spreadMotion = v
elseif key == "crosspos" then
crossSpring.t = v
HudController:toggleCrossHair(not Aimed)
local newS = crossSpring.p * crossScale.p *(Humanoid.WalkSpeed/14*(1-0.8)*2+0.8)*((CharState.currentState == "Running" and 1 or 0)+1)/4
local crossPos = HudController:getCrossPositions(newS)
if not S.gunType.Shot then
HudController:updateCrossHairPositions(crossPos)
end
elseif key == "crossoffset" then
crossOffset = v
elseif key == "currentspread" then
currentSpread = v
end
end
})
end
--
local isDead = false
local cClientClass = require(game.ReplicatedStorage.ChatClient)
local EasingEasel = Utils.CreateGameObject("EasingEasel",90)
RemoteService.listen("Client","Send","ShowImpactFromPoint",function(H,P,N,D,humanoidFound)
local surfaceCF = CF.RAW(P,P + N)
if not H then return end
----------------------------------------------------------------------------------
--Creating the bullet hole--------------------------------------------------------
----------------------------------------------------------------------------------
local Hole = OBJ("Part")
Hole.Transparency = 1
Hole.Anchored = true
Hole.CanCollide = false
Hole.Size = V3(1, 1, 0.2)
Hole.TopSurface = 0
Hole.BottomSurface = 0
if ((not humanoidFound)) then
local Decal = OBJ("Decal")
Decal.Face = Enum.NormalId.Front
Decal.Texture = "rbxassetid://64291977"
Decal.Parent = Hole
Hole.Parent = workspace.HoleStorage
Hole.CFrame = surfaceCF
if (not H.Anchored) then
local Weld = OBJ("Motor6D")
Weld.Part0 = H
Weld.Part1 = Hole
Weld.Parent = Hole
Weld.C0 = CF.TOS(H.CFrame,surfaceCF)
Hole.Anchored = false
end
delay(3, function()
Hole:Destroy()
end)
end
----------------------------------------------------------------------------------
--Creating the spark effect-------------------------------------------------------
----------------------------------------------------------------------------------
spawn(function()
local mat = H.Material
local sId, sVol, sPitch
sId, sVol, sPitch = HitSounds[math.random(1, #HitSounds)], math.random(0.8, 1), math.random(0, 0.6)
local HitSound = Instance.new("Sound")
HitSound.Name = "HitSound"
HitSound.SoundId = "rbxassetid://" .. sId
HitSound.Volume = 1 + sVol
HitSound.EmitterSize = 10
HitSound.MaxDistance = 90
HitSound.Pitch = sPitch
HitSound.Parent = Hole
HitSound:Play()
game.Debris:AddItem(HitSound,1)
end)
if (not humanoidFound) then
local Particles = game.ReplicatedStorage.GunEffectAssets.Sparks:Clone()
Particles:Emit(8)
Particles.Parent = Hole
game.Debris:AddItem(Particles,1)
end
----------------------------------------------------------------------------------
--Creating the smoke effect-------------------------------------------------------
----------------------------------------------------------------------------------
if (not humanoidFound) then
local Particles = game.ReplicatedStorage.GunEffectAssets.Smoke:Clone()
Particles.Color = Sequences.Color.Raw(H.Color);
Particles:Emit(8)
Particles.Parent = Hole
game.Debris:AddItem(Particles,1)
end
end)
RemoteService.listen("Client","Bounce","SpawnFireSound",function(Handle,S,Main)
local fireSound = Handle:FindFirstChild("FireSound")
if fireSound then
if S.fireSoundSettings then
if S.fireSoundSettings.Start then
fireSound.TimePosition = S.fireSoundSettings.Start
end
if S.fireSoundSettings.useSoundRemover then
local fireSoundC = fireSound:Clone()
fireSoundC.Parent = Main
fireSoundC:Play()
fireSoundC.Ended:connect(function()
fireSoundC:Destroy()
end)
else
fireSound:Play()
end
else
fireSound:Play()
end
end
end)
function Particalize(Explosion)
Explosion.Visible = false
local Part = Instance.new("Part")
Part.Name = "ExplosionParticle"
Part.Transparency = 1
Part.Size = V3(15,15,15)
Part.Anchored = true
Part.CanCollide = false
Part.CFrame = CF.RAW(Explosion.Position)
Part.Parent = game.Workspace
local soundPart = Instance.new("Part")
soundPart.Transparency = 1
soundPart.Anchored = true
soundPart.CanCollide = false
soundPart.Size = V3(1, 1, 1)
soundPart.CFrame = CF.RAW(Explosion.Position)
soundPart.Parent = workspace
local Sound = Instance.new("Sound")
Sound.Pitch = 1
Sound.SoundId = "rbxassetid://138499093"
Sound.Volume = 2
Sound.EmitterSize = 20
Sound.Parent = soundPart
Sound:Play()
local C = script:GetChildren()
for i=1,#C do
if C[i].className == "ParticleEmitter" then
local Particle = C[i]:Clone()
Particle.Parent = Part
Particle.Size = NumberSequence.new(Explosion.BlastRadius)
Particle.Enabled = true
end
end
wait(Duration1)
local P = Part:GetChildren()
for i=1,#P do
if P[i].className == "ParticleEmitter" then
P[i].Enabled = false
end
end
if Explosion.Position:isClose(player.Character.Torso.Position,Explosion.BlastRadius * 2) then
CameraService:Shake("Explosion")
end
Debris:AddItem(soundPart, Sound.TimeLength)
Debris:AddItem(Part,Duration2)
end
RemoteService.listen("Client","Bounce","MakeBullet",function(Direction,bCFrame,cartName)
local Cartridge = Cartridges[cartName]
local Bullet = OBJ("Part")
Bullet.BrickColor = BrickColor.White()
Bullet.Material = Enum.Material.Neon
Bullet.Name = "Bullet"
Bullet.CanCollide = false
Bullet.Size = Cartridge.Size
Bullet.BottomSurface = "Smooth"
Bullet.TopSurface = "Smooth"
local TrailFront = OBJ('Attachment')
TrailFront.Position = V3(0.1, 0, 0)
TrailFront.Parent = Bullet
local TrailBack = OBJ('Attachment')
TrailBack.Position = V3(-0.1, 0, 0)
TrailBack.Parent = Bullet
local Trail = OBJ('Trail')
Trail.Attachment0 = TrailFront
Trail.Attachment1 = TrailBack
Trail.Transparency = NumberSequence.new(0)
Trail.LightEmission = 1
Trail.TextureLength = 0.1
Trail.Lifetime = 0.05
Trail.FaceCamera = true
Trail.Parent = Bullet
Trail.Color = ColorSequence.new(Cartridge.Color.Color)
local BF = OBJ ("VectorForce")
BF.Attachment0 = TrailFront
BF.RelativeTo = Enum.ActuatorRelativeTo.World
BF.Force = V3(0, Bullet:GetMass() * (196.2 - Cartridge.Acceleration), 0)
BF.Parent = Bullet
Bullet.CFrame = bCFrame
Bullet.Velocity = Direction * Cartridge.Velocity
Bullet.Parent = workspace.BulletStorage
Bullet.CFrame = bCFrame
delay(10,function()
Bullet:Destroy()
end)
end)
workspace.DescendantAdded:connect(function(Thing)
if Thing.ClassName == "Explosion" and Thing.Visible == true then
Particalize(Thing)
elseif Thing.Name == "BackArm" and not Thing:FindFirstAncestor("gunIgnore_" .. player.Name) then
Thing.LocalTransparencyModifier = 1
end
end)
tween = setmetatable({
tweenFuncs = {
["Joint"] = function(Joint,newC0,newC1,Alpha,Duration)
runAsync(function()
local newCode = RNG:NextInteger(-1e9, 1e9) --This creates a random code between -1000000000 and 1000000000
local tweenIndicator = nil
if (not Joint:FindFirstChild("tweenCode")) then --If the joint isn't being tweened, then
tweenIndicator = Instance.new("IntValue")
tweenIndicator.Name = "tweenCode"
tweenIndicator.Value = newCode
tweenIndicator.Parent = Joint
else
tweenIndicator = Joint:FindFirstChild("tweenCode")
tweenIndicator.Value = newCode --If the joint is already being tweened, this will change the code, and the tween loop will stop
end
if Duration <= 0 then --If the duration is less than or equal to 0 then there's no need for a tweening loop
if newC0 then Joint.C0 = newC0 end
if newC1 then Joint.C1 = newC1 end
else
local startC0 = Joint.C0
local startC1 = Joint.C1
local t0 = tick()
while true do
RunService.Heartbeat:wait()
local X = MIN((tick() - t0) / Duration, 1) * 90
if tweenIndicator.Value ~= newCode then break end --This makes sure that another tween wasn't called on the same joint
if (not Joint) or (not Joint.Parent) then break end --This stops the tween if the tool is deselected
if newC0 then
Joint.C0 = startC0:lerp(newC0, Alpha(X))
RemoteService.send("Server","SetJointC0",Joint,Joint.C0)
end
if newC1 then
Joint.C1 = startC1:lerp(newC1, Alpha(X))
RemoteService.send("Server","SetJointC1",Joint,Joint.C1)
end
if X == 90 then break end
end
end
if tweenIndicator.Value == newCode then --If this tween functions was the last one called on a joint then it will remove the code
tweenIndicator:Destroy()
end
end)
end;
["Cam"] = function(Key,newRot,Alpha,Duration)
runAsync(function()
local newCode = RNG:NextInteger(-1e9, 1e9)
CameraState.camOffsets[Key].Code = newCode
local Increment = 1.5 / Duration
local prevRot = CameraState.camOffsets[Key].Rot
local X = 0
while true do
RunService.Heartbeat:wait()
local newX = X + Increment
X = (newX > 90 and 90 or newX)
if CameraState.camOffsets[Key].Code ~= newCode then break end
if (not CurrentItem.Equipped) then break end
CameraState.camOffsets[Key].Rot = prevRot:lerp(newRot, Alpha(X))
CameraState.camRecoilSpring.t = CameraState.camOffsets[Key].Rot
if X == 90 then break end
end
if CameraState.camOffsets[Key].Code == newCode then
CameraState.camOffsets[Key].Code = nil
end
end)
end;
["textTrans"] = function(textLabel,newTrans,Alpha,Duration)
runAsync(function()
local newCode = RANDOM(-1e9, 1e9) --This creates a random code between -1000000000 and 1000000000
local tweenIndicator = nil
if (not textLabel:FindFirstChild("tweenCode")) then --If the joint isn't being tweened, then
tweenIndicator = Instance.new("IntValue")
tweenIndicator.Name = "tweenCode"
tweenIndicator.Value = newCode
tweenIndicator.Parent = textLabel
else
tweenIndicator = textLabel:FindFirstChild("tweenCode")
tweenIndicator.Value = newCode --If the joint is already being tweened, this will change the code, and the tween loop will stop
end
if Duration <= 0 then --If the duration is less than or equal to 0 then there's no need for a tweening loop
if newTrans then textLabel.TextTransparency = newTrans end
else
local startTrans = textLabel.TextTransparency
local t0 = tick()
while true do
wait(1/60)
local X = MIN((tick() - t0) / Duration, 1) * 90
if tweenIndicator.Value ~= newCode then break end --This makes sure that another tween wasn't called on the same joint
if (not Selected) then break end --This stops the tween if the tool is deselected
if newTrans then textLabel.TextTransparency = Utils.numLerp(startTrans,newTrans,Alpha(X)) end
if X == 90 then break end
end
end
if tweenIndicator.Value == newCode then --If this tween functions was the last one called on a joint then it will remove the code
tweenIndicator:Destroy()
end
end)
end;
["Recoil"] = function(newPos,newRot,Alpha,Duration)
runAsync(function()
local newCode = RNG:NextInteger(-1e9, 1e9)
recoilAnim.Code = newCode
local Increment = 1.5 / Duration
local prevPos = recoilAnim.Pos
local prevRot = recoilAnim.Rot
local X = 0
while true do
RunService.Heartbeat:wait()
local newX = X + Increment
X = (newX > 90 and 90 or newX)
if recoilAnim.Code ~= newCode then break end
if (not CurrentItem.Equipped) then break end
recoilAnim.Pos = prevPos:lerp(newPos, Alpha(X))
recoilAnim.Rot = prevRot:lerp(newRot, Alpha(X))
if X == 90 then break end
end
if recoilAnim.Code == newCode then
recoilAnim.Code = nil
end
end)
end;
["Crawl"] = function(tempCrawlAnim,animEnd)
if not animEnd then
else
end
end;
["Aim"] = function(targetFOV,frames,Alpha)
local currentFOV = CameraService.Cam.FieldOfView
local currentTrans = HudController:getScopeTrans(CurrentItem.Value)
local t0 = tick()
while true do
wait(1/60)
local X = MIN((tick() - t0) / frames, 1) * 90
if currentFOV > targetFOV then
CharState.aimAlpha = Alpha(X)
else
CharState.aimAlpha = 1 - Alpha(X)
end
CharState.aimHeadOffset = CharState:getHeadOffset(CurrentItem.Settings).X * CharState.aimAlpha
CharState.jumpAnimMultiplier = Utils.numLerp(1, CurrentItem.Settings.fallSettings.aimEffect, CharState.aimAlpha)
CharState.armTiltMultiplier = Utils.numLerp(1, 0.2, CharState.aimAlpha)
local lerpedTrans = (currentFOV > targetFOV and Utils.numLerp(currentTrans, 0, CharState.aimAlpha) or Utils.numLerp(1, currentTrans, CharState.aimAlpha))
CameraService.setFOV(currentFOV > targetFOV and Utils.numLerp(currentFOV,targetFOV,CharState.aimAlpha) or Utils.numLerp(targetFOV,currentFOV,CharState.aimAlpha) )
if currentFOV > targetFOV then
if not CurrentItem.Aimed then break end
else
if CurrentItem.Aimed then break end
end
if CurrentItem.Value.BlackScope.Value then
HudController:setScopeTrans(lerpedTrans)
end
if X == 90 then break end
if (not CurrentItem.Equipped) then break end
end
end;
["Bolt"] = function(key,newKick,newRot,Alpha,Duration)
runAsync(function()
local newCode = math.random(-1e9, 1e9)
boltAnim[key].Code = newCode
local Increment = 1.5 / Duration
local prevKick = boltAnim[key].Kick
local prevRot = boltAnim[key].Rot
local X = 0
while true do
RunService.Heartbeat:wait()
local newX = X + Increment
X = (newX > 90 and 90 or newX)
if boltAnim[key].Code ~= newCode then break end
if (not CurrentItem.Equipped) then break end
boltAnim[key].Kick = prevKick:lerp(newKick, Alpha(X))
boltAnim[key].Rot = prevRot:lerp(newRot, Alpha(X))
print("BoltKick:",boltAnim[key].Kick)
print("BoltRot:",boltAnim[key].Rot)
if X == 90 then break end
end
if boltAnim[key].Code == newCode then
boltAnim[key].Code = nil
end
end)
end;
}
}, {
__call = function(self,tweenType,...)
if self.tweenFuncs[tweenType] then
self.tweenFuncs[tweenType](...)
end
end;
__index = function(self,k)
if self.tweenFunc[k] then
return self.tweenFunc[k]
end
end
})
local changePlayerTrans = setmetatable(
{
transModifiers = {
regular = function(self, P, Trans)
for _, v in pairs(P:GetChildren()) do
if v:IsA("BasePart") then
runAsync(function()
v.LocalTransparencyModifier = Trans
end)
end
if not v:FindFirstChild("HoldPart") then
runAsync(function()
self("regular", v, Trans)
end)
end
end
end;
item = function(self, P, Trans, Item)
for _, v in pairs(P:GetChildren()) do
if v:IsA("BasePart") and (not v:IsDescendantOf(Item)) then
runAsync(function()
v.LocalTransparencyModifier = Trans
end)
end
runAsync(function()
self("item", v, Trans, Item)
end)
end
end;
}
},
{
__index = function(self,k)
local key = k:lower()
if rawget(self,"transModifiers")[key] then
return rawget(self,"transModifiers")[key]
end
end;
__newindex = function(self,k,v)
error("Can't set anything in changePlayerTrans")
end;
__call = function(self,transType,...)
self[transType](self,...)
end;
}
)
player.CharacterAdded:connect(function(c)
Character = c
Utils.INSERT(Ignore,Character);
local ignoreMD = workspace.ignoreModel:GetDescendants()
for _, desc in pairs(ignoreMD) do
if desc.Name == "BackArm" and not desc:FindFirstAncestor("gunIgnore_" .. player.Name) then
desc.LocalTransparencyModifier = 1
end
end
local ChatClient = cClientClass.new(player)
ChatClient:Init()
ChatClient:Start()
player.CameraMode = Enum.CameraMode.LockFirstPerson
changePlayerTrans("regular",Character,1)
Character.ChildAdded:connect(function(item)
if item:IsA("Model") then
if item:FindFirstChild("Type") then
local hudType = nil;
if item.Type.Value == "Gun" or item.Type.Value == "Explosive" then
hudType = "Gun"
elseif item.Type.Value == "Grenade" then
hudType = "Grenade"
end
print(hudType)
if hudType then
ViewModel.gunIgnore, ViewModel.playerFolder, ViewModel.headWeld, ViewModel.headWeld2, ViewModel.armBase, ViewModel.animWeld, ViewModel.ABWeld, ViewModel.LWeld, ViewModel.RWeld, ViewModel.LWeld2, ViewModel.RWeld2, ViewModel.LLegWeld, ViewModel.RLegWeld, ViewModel.Grips.Right, ViewModel.Grips.Left = RemoteService.fetch("Server","InitPlayerModel",item,{
Humanoid = Humanoid;
Shoulders = CharacterJoints.Shoulders;
Torso = CharacterParts.Torso;
Head = CharacterParts.Head;
LArm = CharacterParts.LArm;
LLeg = CharacterParts.LLeg;
RLeg = CharacterParts.RLeg;
RArm = CharacterParts.RArm;
armC0 = armC0;
},require(item.SETTINGS))
ViewModel.armModel = RemoteService.fetch("Server","MakeViewModel",require(item.SETTINGS),item,{
Humanoid = Humanoid;
LArm = CharacterParts.LArm;
RArm = CharacterParts.RArm;
playerFolder = ViewModel.playerFolder;
})
ViewModel.fakeLArm = ViewModel.armModel["Left Arm"]
ViewModel.fakeRArm = ViewModel.armModel["Right Arm"]
ViewModel.fakeLWeld = ViewModel.armModel["Left Arm"]:FindFirstChild("FLWeld")
ViewModel.fakeRWeld = ViewModel.armModel["Right Arm"]:FindFirstChild("FRWeld")
ViewModel.fakeHumanoid = ViewModel.armModel.Humanoid
ItemEquipped:fire(item)
HudController = HController.new(item.Name,hudType);
end
end
end
end)
Character.ChildRemoved:connect(function(item)
if item:IsA("Model") then
if item:FindFirstChild("Type") then
ItemUnequipped:fire(item)
HudController = nil;
end
end
end)
Humanoid = Character:WaitForChild("Humanoid",200)
CharacterParts.Torso = Character:WaitForChild("Torso",200)
CharacterParts.Head = Character:WaitForChild("Head",200);
CharacterParts.HRP = Character:WaitForChild("HumanoidRootPart",200)
CharacterParts.LArm = Character:WaitForChild("Left Arm",200)
CharacterParts.RArm = Character:WaitForChild("Right Arm",200)
CharacterParts.LLeg = Character:WaitForChild("Left Leg",200)
CharacterParts.RLeg = Character:WaitForChild("Right Leg",200)
CharacterJoints.Root = CharacterParts.HRP:WaitForChild("RootJoint",200)
CharacterJoints.Neck = CharacterParts.Torso:WaitForChild("Neck",200)
CharacterJoints.Hips.Left = CharacterParts.Torso:WaitForChild("Left Hip",200)
CharacterJoints.Hips.Right = CharacterParts.Torso:WaitForChild("Right Hip",200)
CharacterJoints.Shoulders.Left = CharacterParts.Torso:WaitForChild("Left Shoulder",200)
CharacterJoints.Shoulders.Right = CharacterParts.Torso:WaitForChild("Right Shoulder",200)
IEC = ItemEquipped:connect(function(item)
local itemReady = false
if item then
if item:FindFirstChild("Type") then
CurrentItem.Type = item.Type.Value
if item.Type.Value == "Grenade" then
changePlayerTrans("item",Character, 1,item)
UIS.MouseBehavior = "LockCenter"
CameraAng = VEC2(Utils.getYawPitch(CameraService.Cam.CFrame))
InputComp:AddInputScheme("Grenade",{
{"Basic",{"Throw","Sprint","lowerStance","raiseStance"}}
});
local Throwing = false
InputComp:RegisterSchemeAction("Grenade","Throw",{Enum.UserInputType.MouseButton1},false,function(input,gp)
if not Throwing then
Throwing = true
CurrentItem:PlayAnimation("Throwing");
RemoteService.send("Server","DiscardNade",CurrentItem.Value)
Throwing = false
end
end,true,1)
InputComp.CurrentIScheme = "Grenade";
InputComp.Sensitivity.aim = RemoteService.fetch("Server","GetSensitivity","Gun")
InputComp.Sensitivity.mouse = InputComp.Sensitivity.aim;
changeKeybindIMode("Grenade")
CameraService:setCamMode("FirstPersonFireArm",CameraAng,getTotalCamOffset.grenade,CharacterParts.Head)
itemReady = true;
elseif item.Type.Value == "Gun" then
UIS.MouseBehavior = "LockCenter"
local initialX, initialY = Utils.getYawPitch(CharacterParts.Head.CFrame)
if CameraService.Angles.magnitude > 0 then
CameraAng = CameraService.Angles
else
CameraAng = -VEC2(initialX, initialY)
end
local camMode = RemoteService.fetch("Server","GetWeaponCMode","Gun")
if camMode == "FirstPersonFireArm" then
changePlayerTrans("item",Character, 1,item)
end
InputComp:AddInputScheme("Gun",{
{
"Basic";
{
"ADS";
"Sprint";
"scopeSteady";
"raiseStance";
"lowerStance";
"selectFire";
"Reload";
};
};
{
"Tactical";
{
"Spot";
"ThrowTactical";
"ThrowLethal";
"BoltAction";
"ToggleBipod";
};
};
{
"Cosmetic";
{
"Inspect";
};
};
},{Enum.UserInputType.MouseButton1,Enum.KeyCode.ButtonR2});
changeKeybindIMode("Gun")
InputComp:SetActivationCB("Gun",function(input,gp)
if CurrentItem.Equipped then
CurrentItem.FiringSystem:runMode(CurrentItem.firingApi)
end
end)
InputComp:RegisterSchemeAction("Gun","selectFire",{Enum.KeyCode[Keybinds.selectFire]},false,function(input,gp)
if CurrentItem.FiringSystem then
if CurrentItem.Settings.selectFire and CurrentItem.canSelectFire then
CurrentItem.canSelectFire = false
CurrentItem.FiringSystem:changeMode();
local speedAlpha = CurrentItem.Settings.selectFireSettings.animSpeed / 0.6
if (not CurrentItem.Aimed) and (CharState.currentState ~= "Running") and (not CharState.currentState ~= "Crawling") then
runAsync(function()
local sequenceTable = {
function()
tween("Joint", ViewModel.RWeld2, nil, CF.ANG(0, RAD(5), 0), EasingEasel:getAlpha("Sine@Out"), speedAlpha * 0.15)
tween("Joint",ViewModel.LWeld, armC0[1], CF.RAW(0.1, 1, -0.3) * CF.ANG(RAD(-7), 0, RAD(-65)), EasingEasel:getAlpha("Linear@Out"), speedAlpha * 0.15)
wait(speedAlpha * 0.2)
end;
function()
tween("Joint",ViewModel.LWeld, armC0[1], CF.RAW(0.1, 1, -0.3) * CF.ANG(RAD(-10), 0, RAD(-65)), EasingEasel:getAlpha("Linear@Out"), speedAlpha * 0.1)
wait(speedAlpha * 0.2)
end;
function()
tween("Joint",ViewModel.RWeld2, nil, CF.RAW(), EasingEasel:getAlpha("Sine@Out"), speedAlpha * 0.2)
tween("Joint",ViewModel.LWeld, armC0[1], CurrentItem.Settings.unAimedC1.leftArm, EasingEasel:getAlpha("Sine@Out"), speedAlpha * 0.2)
wait(speedAlpha * 0.2)
end;
}
for _, F in pairs(sequenceTable) do
if CharState.currentState == "Crawling" or CharState.currentState == "Running" then
break
end
F()
end
end)
end
if not BindableService.fetch("CallSignAlreadyRan","selectFireActivated") then
BindableService.send("MarkCallSign","selectFireActivated")
end
CurrentItem.canSelectFire = true
end
end
end,true,1)
InputComp:RegisterSchemeAction("Gun","ADS",{Enum.KeyCode[Keybinds.ADS]},false,function(input,gp)
if CurrentItem.Equipped then
if CurrentItem.Aimed then
CurrentItem:unAimGun()
else
CurrentItem:aimGun()
end
end
end,true,1)
InputComp:RegisterSchemeAction("Gun","raiseStance",{Enum.KeyCode[Keybinds.raiseStance]},false,function(input,gp)
if CharState.currentState == "Running" then return end
if CharState.Stance == 2 then
if CurrentItem.Settings.stanceSettings.Stances.Crouch then
CurrentItem:changeStance("Crouch")
else
CurrentItem:changeStance("Stand")
end
elseif CharState.Stance == 1 then
CurrentItem:changeStance("Stand")
end
end,true,1)
InputComp:RegisterSchemeAction("Gun","lowerStance",{Enum.KeyCode[Keybinds.lowerStance]},false,function(input,gp)
if CharState.currentState ~= "Running" then
if CharState.Stance == 0 then
if CurrentItem.Settings.stanceSettings.Stances.Crouch then
CurrentItem:changeStance("Crouch")
elseif CurrentItem.Settings.stanceSettings.Stances.Prone then
CurrentItem:changeStance("Prone")
end
elseif CharState.Stance == 1 then
if CurrentItem.Settings.stanceSettings.Stances.Prone then
CurrentItem:changeStance("Prone")
end
end
elseif CurrentItem.Settings.dolphinDive then
-- S.Humanoid.Jump = true
wait()
if Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and (not UIS:IsKeyDown("Space")) and InputComp:IsInputDown(Enum.KeyCode[Keybinds.Sprint]) then
local tempConnection = Humanoid.Changed:connect(function()
Humanoid.Jump = false
end)
CharState.runReady = false
CurrentItem:changeStance("Dive")
CharState.currentState = "None";
wait(CurrentItem.Settings.diveSettings.rechargeTime)
tempConnection:disconnect()
CharState.runReady = true
end
end
end,true,1)
InputComp.CurrentIScheme = "Gun";
InputComp.Sensitivity.aim = RemoteService.fetch("Server","GetSensitivity","Gun")
InputComp.Sensitivity.mouse = InputComp.Sensitivity.aim;
CameraService:setCamMode(camMode,CameraAng,getTotalCamOffset.gun,CharacterParts.Head)
CameraService.setFOV(80)
itemReady = true;
end
end
end
if itemReady then
CurrentItem.Value = item;
CurrentItem.Settings = require(item.SETTINGS);
if (CurrentItem.Settings) then
if CurrentItem.Value then
HudController.UI.Visible = true;
HudController:toggleCrossHairMode(CurrentItem.Settings.gunType.Shot and "shotgun" or "regular")
CharState.walkSpeed = CurrentItem.Settings.baseWalkSpeed;
CurrentItem:LoadAnim(CurrentItem.Value)
if CurrentItem.Type == "Grenade" then
runAsync(function()
tween("Joint",ViewModel.LWeld, nil, CurrentItem.Settings.regularC1.leftArm, EasingEasel:getAlpha("Sine@Out"), CurrentItem.Settings.equipSettings.Time)
tween("Joint",ViewModel.RWeld, nil, CurrentItem.Settings.regularC1.rightArm, EasingEasel:getAlpha("Sine@Out"), CurrentItem.Settings.equipSettings.Time)
tween("Joint",ViewModel.Grips.Right, nil, CurrentItem.Settings.regularC1.Grip, EasingEasel:getAlpha("Sine@Out"), CurrentItem.Settings.equipSettings.Time)
end)
elseif CurrentItem.Type == "Gun" then
CurrentItem.SlidePart = CurrentItem.Value:WaitForChild("SlidePart",200)
local mainList = {}
for _, main in pairs(CurrentItem.Value:GetChildren()) do
if main.Name == "Main" then
if main:IsA("BasePart") then
if main:FindFirstChild("BarrelIndex") then
if tonumber(main.BarrelIndex.Value) then
CurrentItem.Main[main.BarrelIndex.Value] = main
end
end
end
end
end
CurrentItem.FiringSystem = Utils.CreateGameObject("FiringSystem",HudController);
for i, v in pairs(CurrentItem.Settings.selectFireSettings.Modes) do
CurrentItem.FiringSystem:addFireMode(v:upper())
end
if #CurrentItem.Main >= 2 and CurrentItem.Value:FindFirstChild("GrenadeCaliber") then
CurrentItem.FiringSystem:addFireMode(("Grenade"):upper())
end
CurrentItem.FiringSystem:sortModes(CurrentItem.Settings.defaultMode)
CurrentItem.Firingsystem:showMode()
CurrentItem.Equipped = false
BoltWelds = RemoteService.fetch("Server","GetBoltWelds")
for key,boltWeld in pairs(BoltWelds) do
if key then
boltAnim[key] = {
Kick = V3();
Rot = V3();
Code = 0;
};
end
end;
runAsync(function()
tween("Joint",ViewModel.LWeld, nil, CurrentItem.Settings.unAimedC1.leftArm, EasingEasel:getAlpha("Sine@Out"), CurrentItem.Settings.equipSettings.Time)
tween("Joint",ViewModel.RWeld, nil, CurrentItem.Settings.unAimedC1.rightArm, EasingEasel:getAlpha("Sine@Out"), CurrentItem.Settings.equipSettings.Time)
tween("Joint",ViewModel.Grips.Right, nil, CurrentItem.Settings.unAimedC1.Grip, EasingEasel:getAlpha("Sine@Out"), CurrentItem.Settings.equipSettings.Time)
delay(CurrentItem.Settings.equipSettings.Time,function()
CurrentItem.Equipped = true;
end)
end)
end
end
end
end
end)
IAC = InputComp.AxisChanged:connect(function(axisInput)
if CurrentItem.Value then
local rawCamAng = CameraAng - axisInput
CameraAng = VEC2(rawCamAng.x, (rawCamAng.y > RAD(80) and RAD(80) or rawCamAng.y < RAD(-80) and RAD(-80) or rawCamAng.y))
end
end)
IUEC = ItemUnequipped:connect(function(item)
if item then
if item:FindFirstChild("Type") then
if item.Type.Value == "Grenade" then
InputComp:RemoveInputScheme("Grenade")
elseif item.Type.Value == "Gun" then
CurrentItem.FiringSystem.clearModes();
CurrentItem.FiringSystem = nil;
CurrentItem.Aimed = false
CurrentItem.Equipped = false
endRun()
InputComp:RemoveInputScheme("Gun")
end
RemoteService.send("Server","ResetViewModel", {
gunIgnore = ViewModel.gunIgnore;
Shoulders = CharacterJoints.Shoulders;
LArm = CharacterParts.LArm;
RArm = CharacterParts.RArm;
Grips = ViewModel.Grips;
})
ViewModel = {
gunIgnore = nil;
playerFolder = nil;
headWeld = nil;
headWeld2 = nil;
armBase = nil;
animWeld = nil;
ABWeld = nil;
LWeld = nil;
RWeld = nil;
LWeld2 = nil;
RWeld2 = nil;
LLegWeld = nil;
RLegWeld = nil;
Grips = {
Left = nil;
Right = nil;
Current = "Right";
};
armModel = nil;
fakeLArm = nil;
fakeRArm = nil;
fakeHumanoid = nil;
fakeLWeld = nil;
fakeRWeld = nil;
}
CurrentItem.Value = nil;
player.CameraMode = Enum.CameraMode.LockFirstPerson
CameraService.CurrentModeVars:Stop()
CameraService:setCamMode("Regular",Character)
changePlayerTrans("regular",Character,1)
CharState.currentState = "Idling";
changeKeybindIMode("Gun")
CharState.runReady = true
CharState.grounded = true
end
end
end)
Humanoid.HealthChanged:connect(function(health)
if health <= 0 and not isDead then
isDead = true
local now = tick()
if (now - deathRecieve) > 1 then
PingDeath:wait()
end
Character.Humanoid:SetStateEnabled("Dead",true)
Character.Humanoid:ChangeState("Dead")
changePlayerTrans("regular",Character,0)
end
end)
--[[
RunService:BindToRenderStep("CrawlLoop",Enum.RenderPriority.Character.Value,function(dt)
elseif CharState.currentState ~= "Crawling" and CharState.CrawlTransition then
end
end
end)
]]--
local ct0 = tick()
spawn(function()
while true do
RunService.Heartbeat:wait()
if CurrentItem.Value then
if CharState.currentState == "Crawling" then
CurrentItem.breakReload = (CurrentItem.Reloading and true or CurrentItem.breakReload)
local tempCrawlAnim = CurrentItem.Animations.Crawling(CharState.crawlAng, CharState.moveAng)
if CurrentItem.Aimed then CurrentItem:unAimGun(true) end
runAsync(function()
local startCamRot = crawlCamRot
local startLLegCF = ViewModel.LLegWeld.C1
local startRLegCF = ViewModel.RLegWeld.C1
local t0 = tick()
while true do
RunService.Heartbeat:wait()
local Alpha = MIN((tick() - t0) * 3.33333, 1) * 90
if (CharState.currentState ~= "Crawling") then break end
if (not CurrentItem.Equipped) then break end
crawlCamRot = Utils.numLerp(startCamRot, tempCrawlAnim.Camera, EasingEasel:getAlpha("Sine@Out")(Alpha))
ViewModel.LLegWeld.C1 = startLLegCF:lerp(tempCrawlAnim.leftLeg, EasingEasel:getAlpha("Linear@Out")(Alpha))
ViewModel.RLegWeld.C1 = startRLegCF:lerp(tempCrawlAnim.rightLeg, EasingEasel:getAlpha("Linear@Out")(Alpha))
RemoteService.send("Server","SetJointC1",ViewModel.LLegWeld,ViewModel.LLegWeld.C1)
RemoteService.send("Server","SetJointC1",ViewModel.RLegWeld,ViewModel.RLegWeld.C1)
if Alpha == 90 then break end
end
end)
tween("Joint",ViewModel.LWeld, nil, tempCrawlAnim.leftArm, EasingEasel:getAlpha("Linear@Out"), 0.3)
tween("Joint",ViewModel.RWeld, nil, tempCrawlAnim.rightArm, EasingEasel:getAlpha("Linear@Out"), 0.3)
tween("Joint",ViewModel.Grips.Right, nil, tempCrawlAnim.Grip, EasingEasel:getAlpha("Linear@Out"), 0.3)
CurrentItem:lowerSpread()
crawlReady = true
local ct0 = tick()
while true do
local dt = RunService.Heartbeat:wait()
if CharState.currentState ~= "Crawling" or not CurrentItem.Equipped then break end
if (tick() - ct0) >= 0.3 then
local crawlAnim = CurrentItem.Animations.Crawling(CharState.crawlAng, CharState.moveAng)
ViewModel.RWeld.C1 = crawlAnim.rightArm
ViewModel.RWeld.C1 = crawlAnim.rightArm
ViewModel.LWeld.C1 = crawlAnim.leftArm
ViewModel.LLegWeld.C1 = crawlAnim.leftLeg
ViewModel.RLegWeld.C1 = crawlAnim.rightLeg
ViewModel.Grips.Right.C1 = crawlAnim.Grip
print("Crawl")
RemoteService.send("Server","SetJointC1",ViewModel.LLegWeld,ViewModel.LLegWeld.C1)
RemoteService.send("Server","SetJointC1",ViewModel.RLegWeld,ViewModel.RLegWeld.C1)
RemoteService.send("Server","SetJointC1",ViewModel.Grips.Right,ViewModel.Grips.Right.C1)
RemoteService.send("Server","SetJointC1",ViewModel.LWeld,ViewModel.LWeld.C1)
RemoteService.send("Server","SetJointC1",ViewModel.RWeld,ViewModel.RWeld.C1)
CharState.crawlCamRot = crawlAnim.Camera
CharState.crawlAng = CharState.crawlAng + 0.5 * RAD(105 * dt) * (CharacterParts.HRP.Velocity * V3(1, 0, 1)).magnitude * 0.333333333
end
end
else
crawlReady = false
end
end
end
end)
RunService:BindToRenderStep("RunMainAnim",Enum.RenderPriority.Character.Value,function(dt)
if CurrentItem.Value then
local iType = CurrentItem.Type
if iType then
iType = iType:lower()
local args = {}
if CurrentItem.Type == "Gun" then
args[1] = "General"
end
if CharState.animCF[iType] then
local animC0, animC1 = CharState.animCF[iType](unpack(args))
ViewModel.animWeld.C0 = animC0
ViewModel.animWeld.C1 = animC1
RemoteService.send("Server","SetAJointC0",ViewModel.animWeld,animC0)
RemoteService.send("Server","SetAJointC1",ViewModel.animWeld,animC1)
pcall(function()
for key, weld in pairs(BoltWelds) do
weld.C1 = CharState.animCF.gun("Bolt",key)
RemoteService.send("Server","SetJointC1",weld,weld.C1)
end
end)
end
end
end
end)
RunService:BindToRenderStep("UpdateCamAng",Enum.RenderPriority.Camera.Value,function(dt)
if CurrentItem.Value then
UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
if CameraService.CurrentCamMode == "FirstPersonFireArm" and CurrentItem.Value then
changePlayerTrans("item",Character, 1,CurrentItem.Value)
end
local finalCamOffset
if CurrentItem.Type == "Gun" then
finalCamOffset = getTotalCamOffset.gun()
CameraService:SetRoll(CharState.crawlCamRot + finalCamOffset.Z)
elseif CurrentItem.Type == "Grenade" then
finalCamOffset = getTotalCamOffset.grenade()
end
ViewModel.headWeld.C1 = CF.ANG(-CameraAng.y - finalCamOffset.Y, 0, 0)
CharacterParts.HRP.CFrame = CF.RAW(CharacterParts.HRP.Position) * CF.ANG(0, CameraAng.x + finalCamOffset.X, 0)
RemoteService.send("Server","SetJointC1",ViewModel.headWeld,ViewModel.headWeld.C1)
CameraService.CurrentModeVars.camAng = CameraAng
end
end)
RunService:BindToRenderStep("UpdateWalkSpeed",Enum.RenderPriority.Character.Value,function(dt)
CharState.walkSpeed = CharState:calcWalkSpeed(CurrentItem.Settings and CurrentItem.Settings.baseWalkSpeed or 14)
Humanoid.WalkSpeed = CharState.walkSpeed
end)
RunService:BindToRenderStep("UpdateState",Enum.RenderPriority.Character.Value,function(dt)
local Velocity =CharacterParts.Torso.CFrame:vectorToObjectSpace(CharacterParts.Torso.Velocity)
if (CharState.Stance == 2 and CharState.grounded) and Velocity.magnitude >= 3.5 and (Humanoid.MoveDirection.magnitude > 0) and CurrentItem.Value then
CharState.CrawlTransition = true
CharState.currentState = "Crawling"
CharState.CrawlTransition = false
elseif ((not CharState.grounded) and true or (Velocity.magnitude == 0 or Humanoid.MoveDirection.magnitude <= 0) ) then
if CharState.currentState == "Crawling" then
spawn(function()
CharState.CrawlTransition = true
CharState.crawlAng = 0
local tempCrawlAnim = CurrentItem.Animations.Crawling(CharState.crawlAng, CharState.moveAng)
runAsync(function()
local startCamRot = crawlCamRot
local startLLegCF = ViewModel.LLegWeld.C1
local startRLegCF = ViewModel.RLegWeld.C1
local t0 = tick()
while true do
RunService.Heartbeat:wait()
local Alpha = MIN((tick() - t0) * 3.333333333, 1) * 90
if (CharState.currentState ~= "Crawling") then break end
if (not CurrentItem.Equipped) then break end
crawlCamRot = Utils.numLerp(startCamRot, 0, EasingEasel:getAlpha("Sine@Out")(Alpha))
ViewModel.LLegWeld.C1 = startLLegCF:lerp(CF.RAW(), EasingEasel:getAlpha("Linear@Out")(Alpha))
ViewModel.RLegWeld.C1 = startRLegCF:lerp(CF.RAW(), EasingEasel:getAlpha("Linear@Out")(Alpha))
if Alpha == 90 then break end
end
end)
tween("Joint",ViewModel.LWeld, nil, CurrentItem.Settings.unAimedC1.leftArm, EasingEasel:getAlpha("Sine@Out"), 0.3)
tween("Joint",ViewModel.RWeld, nil, CurrentItem.Settings.unAimedC1.rightArm, EasingEasel:getAlpha("Sine@Out"), 0.3)
tween("Joint",ViewModel.Grips.Right, nil, CurrentItem.Settings.unAimedC1.Grip, EasingEasel:getAlpha("Sine@Out"), 0.3)
repeat wait() until CharState.currentState == "Idling"
CharState.CrawlTransition = false
end)
end
CharState.currentState = "Idling"
elseif ((CharState.Stance ~= 2) and (Velocity.magnitude > 0 and Velocity.magnitude <= 16) and CharState.grounded) then
if CharState.currentState == "Crawling" then
spawn(function()
CharState.CrawlTransition = true
CharState.crawlAng = 0
local tempCrawlAnim = CurrentItem.Animations.Crawling(CharState.crawlAng, CharState.moveAng)
runAsync(function()
local startCamRot = crawlCamRot
local startLLegCF = ViewModel.LLegWeld.C1
local startRLegCF = ViewModel.RLegWeld.C1
local t0 = tick()
while true do
RunService.Heartbeat:wait()
local Alpha = MIN((tick() - t0) * 3.333333333, 1) * 90
if (CharState.currentState ~= "Crawling") then break end
if (not CurrentItem.Equipped) then break end
crawlCamRot = Utils.numLerp(startCamRot, 0, EasingEasel:getAlpha("Sine@Out")(Alpha))
ViewModel.LLegWeld.C1 = startLLegCF:lerp(CF.RAW(), EasingEasel:getAlpha("Linear@Out")(Alpha))
ViewModel.RLegWeld.C1 = startRLegCF:lerp(CF.RAW(), EasingEasel:getAlpha("Linear@Out")(Alpha))
if Alpha == 90 then break end
end
end)
tween("Joint",ViewModel.LWeld, nil, CurrentItem.Settings.unAimedC1.leftArm, EasingEasel:getAlpha("Sine@Out"), 0.3)
tween("Joint",ViewModel.RWeld, nil, CurrentItem.Settings.unAimedC1.rightArm, EasingEasel:getAlpha("Sine@Out"), 0.3)
tween("Joint",ViewModel.Grips.Right, nil, CurrentItem.Settings.unAimedC1.Grip, EasingEasel:getAlpha("Sine@Out"), 0.3)
repeat wait() until CharState.currentState == "Walking"
CharState.CrawlTransition = false
end)
end
CharState.currentState = "Walking"
elseif ((CharState.Stance == 0) and (Velocity.magnitude > 0 and Velocity.magnitude >= 20) and CharState.grounded and not CurrentItem.Aimed) then
if CharState.currentState == "Crawling" then
spawn(function()
CharState.CrawlTransition = true
repeat wait() until CharState.currentState == "Running"
CharState.CrawlTransition = false
end)
end
CharState.currentState = "Running"
end
print(CharState.currentState)
end)
function beginRun()
if CurrentItem.Equipped and not CurrentItem.Reloading and (Humanoid.MoveDirection.Z < 0) then
CurrentItem.crossOffset = 50
if CharState.Stance == 1 or CharState.Stance == 2 then
CurrentItem:changeStance("Stand")
end
if CurrentItem.Settings.canFireWhileRunning then
tween("Joint",ViewModel.LWeld, armC0[1], CurrentItem.Settings.unAimedC1.leftArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.RWeld, armC0[2], CurrentItem.Settings.unAimedC1.rightArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.Grips.Right, nil, CurrentItem.Settings.unAimedC1.Grip, EasingEasel:getAlpha("Sine@Out"), 0.4)
else
tween("Joint",ViewModel.LWeld, armC0[1], CurrentItem.Settings.runningC1.leftArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.RWeld, armC0[2], CurrentItem.Settings.runningC1.rightArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.Grips.Right, nil, CurrentItem.Settings.runningC1.Grip, EasingEasel:getAlpha("Sine@Out"), 0.4)
end
end
end
function endRun()
if CurrentItem.Equipped and not CurrentItem.Aimed and not CurrentItem.Reloading then
CurrentItem.crossOffset = 0
tween("Joint",ViewModel.LWeld, armC0[1], CurrentItem.Settings.unAimedC1.leftArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.RWeld, armC0[2], CurrentItem.Settings.unAimedC1.rightArm, EasingEasel:getAlpha("Sine@Out"), 0.4)
tween("Joint",ViewModel.Grips.Right, nil, CurrentItem.Settings.unAimedC1.Grip, EasingEasel:getAlpha("Sine@Out"), 0.4)
end
end
IBE = UIS.InputBegan:connect(function(input,gp)
if not gp then
if input.KeyCode == Enum.KeyCode[Keybinds.Sprint] and CharState.runReady then
if CurrentItem.Aimed and not CurrentItem.Value.BlackScope.Value then CurrentItem:unAimGun(true) end
repeat wait() until CharState.currentState == "Running"
beginRun()
end
end
end)
IEE = UIS.InputEnded:connect(function(input,gp)
if not gp then
if input.KeyCode == Enum.KeyCode[Keybinds.Sprint] and CharState.runReady then
repeat wait() until CharState.currentState ~= "Running"
endRun()
end
end
end)
RunService:BindToRenderStep("UpdateAnims",Enum.RenderPriority.Character.Value,function(dt)
if CurrentItem.Value and CurrentItem.Animations and CurrentItem.Equipped then
local Increment = 90 * 2.5 --1.5 / 0.4
CharState.crawlAlpha = MIN(MAX(CharState.crawlAlpha + ((CharState.currentState == "Crawling") and Increment or -Increment) * dt, 0), 90)
CharState.idleAlpha = MIN(MAX(CharState.idleAlpha + ((CharState.currentState == "Idling") and Increment or -Increment) * dt, 0), 90)
CharState.walkAlpha = MIN(MAX(CharState.walkAlpha + ((CharState.currentState == "Walking") and Increment or -Increment) * dt, 0), 90)
CharState.runAlpha = MIN(MAX(CharState.runAlpha + ((CharState.currentState == "Running") and Increment or -Increment) * dt, 0), 90)
local posHip = (
EasingEasel:getAlpha("Sine@Out")(CharState.idleAlpha) * (CurrentItem.Animations.Idling["unAimed"](CharState.baseAnim.Ang)).Pos
) + (
EasingEasel:getAlpha("Sine@Out")(CharState.walkAlpha) * (CurrentItem.Animations.Walking["unAimed"](CharState.baseAnim.Ang)).Pos
) + (
EasingEasel:getAlpha("Sine@Out")(CharState.runAlpha) * (CurrentItem.Animations.Running(CharState.baseAnim.Ang)).Pos
)
local rotHip = (
EasingEasel:getAlpha("Sine@Out")(CharState.idleAlpha) * (CurrentItem.Animations.Idling["unAimed"](CharState.baseAnim.Ang)).Rot
) + (
EasingEasel:getAlpha("Sine@Out")(CharState.walkAlpha) * (CurrentItem.Animations.Walking["unAimed"](CharState.baseAnim.Ang)).Rot
) + (
EasingEasel:getAlpha("Sine@Out")(CharState.runAlpha) * (CurrentItem.Animations.Running(CharState.baseAnim.Ang)).Rot
)
local posAim = (
EasingEasel:getAlpha("Sine@Out")(CharState.idleAlpha) * (CurrentItem.Animations.Idling["Aimed"](CharState.baseAnim.Ang)).Pos
) + (
EasingEasel:getAlpha("Sine@Out")(CharState.walkAlpha) * (CurrentItem.Animations.Walking["Aimed"](CharState.baseAnim.Ang)).Pos
) + (
EasingEasel:getAlpha("Sine@Out")(CharState.runAlpha) * (CurrentItem.Animations.Running(CharState.baseAnim.Ang)).Pos
)
local rotAim = (
EasingEasel:getAlpha("Sine@Out")(CharState.idleAlpha) * (CurrentItem.Animations.Idling["Aimed"](CharState.baseAnim.Ang)).Rot
) + (
EasingEasel:getAlpha("Sine@Out")(CharState.walkAlpha) * (CurrentItem.Animations.Walking["Aimed"](CharState.baseAnim.Ang)).Rot
) + (
EasingEasel:getAlpha("Sine@Out")(CharState.runAlpha) * (CurrentItem.Animations.Running(CharState.baseAnim.Ang)).Rot
)
CharState.baseAnim.Pos = (1 - CharState.aimAlpha) * posHip + CharState.aimAlpha * posAim
CharState.baseAnim.Rot = (1 - CharState.aimAlpha) * rotHip +CharState. aimAlpha * rotAim
CharState.baseAnim.Ang = CharState.baseAnim.Ang + RAD(105 * dt) * CharState.stanceSway
CurrentItem.crossPos = (CurrentItem.Aimed and -2 or ( CurrentItem.crossOffset + (CurrentItem.baseSpread + CurrentItem.currentSpread) * 50))
end
end)
local nextWeapon = RemoteService.fetch("Server","GetLoadoutItem",1)
RemoteService.send("Server","UnequipItems")
RemoteService.send("Server","EquipItem",nextWeapon)
end)
player.CharacterRemoving:connect(function(c)
RunService:UnbindFromRenderStep("UpdateCamAng");
RunService:UnbindFromRenderStep("UpdateWalkSpeed");
RunService:UnbindFromRenderStep("UpdateState");
RunService:UnbindFromRenderStep("UpdateAnims");
IUEC:disconnect();
IEC:disconnect()
Utils.REMOVE(Ignore,Character);
end)
RemoteService.listen("Client","Fetch","PingDeath",function()
if Character then
PingDeath:fire()
deathRecieve = tick()
return true
end
return false
end)
player.CharacterRemoving:connect(function(c)
wait(5)
CameraService:setCamMode("IntermissionMenu","Main")
end)
RemoteService.listen("Client","Send","MarkHit",function()
if HudController then
if HudController.UI then
if HudController.markHit then
print("MarkHit")
HudController:markHit()
end
end
end
end)
RemoteService.listen("Client","Send","MuzzleFlash",function(main)
for _, v in pairs(main:GetChildren()) do
if v.Name:find("FlashFX") then
v.Enabled = true
end
end
delay(0.05, function()
for _, v in pairs(main:GetChildren()) do
if v.Name:find("FlashFX") then
v.Enabled = false
end
end
end)
end)
function getClosestPickup()
local result = nil
for _, pickup in pairs(workspace.LootIgnore:GetChildren()) do
if pickup:IsA("Model") then
if (Character.Torso.CFrame.p - pickup:GetPrimaryPartCFrame().p).magnitude <= 10 then
result = pickup
break
end
end
end
return result
end
local pickupTick = tick()
RunService:BindToRenderStep("SearchGunPickup",Enum.RenderPriority.Last.Value,function(dt)
if (tick() - pickupTick) >= 0.2 then
pickupTick = tick()
GunPickup = getClosestPickup()
if GunPickup then
if #UIS:GetConnectedGamepads() >0 then
BindableService.send("ShowPickupInfo",Enum.UserInputType.Gamepad1,Enum.KeyCode.DPadDown,GunPickup.Name)
elseif UIS.KeyboardEnabled then
BindableService.send("ShowPickupInfo",Enum.UserInputType.Keyboard,Enum.KeyCode.Six,GunPickup.Name)
elseif UIS.TouchEnabled then
end
else
BindableService.send("HidePickupInfo")
end
end
end)
BindableService.listen("Send","ToggleInGameSens",function()
IGSEnabled = not IGSEnabled
end)
BindableService.listen("Fetch","IsIGSEnabled" ,function()
return IGSEnabled
end)
UIS.InputBegan:connect(function(input,gp)
if not gp then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Six then
if GunPickup then
RemoteService.send("Server","PickupGun",GunPickup)
GunPickup = nil
end
end
elseif input.UserInputType.Name:find("Gamepad") then
if input.KeyCode == Enum.KeyCode.DPadDown then
if GunPickup then
RemoteService.send("Server","PickupGun",GunPickup)
GunPickup = nil
end
end
end
end
end)
RemoteService.listen("Client","Send","RegisterGun",function(gun)
spawn(function() require(gun.clientMain)() end)
end)
RemoteService.listen("Client","Send","ShakeCamera",function(preset)
CameraService:Shake(preset)
end)
BindableService.start()
RemoteService.startClient()
local SaveGameService = require(game.ServerScriptService.SaveGameService)
local InventoryService = require(game.ReplicatedStorage.InventoryService)
local ItemStorage = require(game.ReplicatedStorage.ItemStorage)
local RemoteService = require(game.ReplicatedStorage.RemoteService)
local AttachmentsList = require(game.ReplicatedStorage.Settings.Attachments)
local TweenService = game:GetService("TweenService")
local saveGameContainers = {}
local AchievementCache = {}
local PhysicsService = game:GetService("PhysicsService")
local BindableService = require(game.ReplicatedStorage.BindingService)()
local AchievementObj = require(game.ReplicatedStorage.Achievement)
local KillService = require(game.ServerScriptService.KillService)
local AchievementList = require(game.ReplicatedStorage.Settings.Achievements)
local Detonator = require(game.ReplicatedStorage.GunLibraries.Detonator)
local Cheats = require(game.ReplicatedStorage.Settings.Cheats)
local Round = require(game.ReplicatedStorage.Round)
local ProgressionService = require(game.ReplicatedStorage.ProgressionService)
local Lighting = game:GetService("Lighting")
local Cartridges = require(game.ReplicatedStorage.Settings.Cartridges)
local achievementPlayerFunctions = {}
local PlayerLoadouts = {}
local AttachmentLibraries = {}
local Grips = {}
local animWelds = {};
local gunIgnores = {}
local CurrentMap
local currentRound = nil
local DS = game:GetService("Debris")
local raycast = workspace.FindPartOnRayWithIgnoreList
local RNG = Random.new()
local DamageTag = require(game.ReplicatedStorage.DamageTag)
local RPGM = require(game.ReplicatedStorage.RPGMathProvider)
_G.GameMode = "TDM";
_G.Outfits = true;
local inList = function(Element, List)
for _, v in pairs(List) do
if v == Element then
return true
end
end
return false
end
local RS = game:GetService("RunService")
local CamoCache = {}
local ChatServer = require(game.ReplicatedStorage.ChatServer)
local ChatSI = ChatServer.new()
local AntiSpeed = require(script.AntiSpeed)
local OBJ = Instance.new
local V3 = Vector3.new
local CF = CFrame.new
local RAY = Ray.new
local RAD = math.rad
local WS = workspace
local Utils = require(game.ReplicatedStorage.UtilService)
local CFANG = CFrame.Angles
local GunBuilders = {}
local BoltWelds = {}
local sheatheModels = {}
local sheatheWelds = {}
function addBolt(player,bolt,slidepart)
if bolt:FindFirstChild("BoltRole") then
if bolt.BoltRole:IsA("StringValue") then
if bolt.Name == "Bolt" then
bolt.Anchored = true
local bRole = bolt.BoltRole.Value
BoltWelds[player][bRole] = Instance.new("Motor6D")
BoltWelds[player][bRole].Name = "BoltWeld"
BoltWelds[player][bRole].Part0 = slidepart
BoltWelds[player][bRole].Part1 = bolt
BoltWelds[player][bRole].C0 = slidepart.CFrame:toObjectSpace(bolt.CFrame)
BoltWelds[player][bRole].C1 = CF()
BoltWelds[player][bRole].Parent = slidepart
bolt.Anchored = false
end
end
end
end
function findBolt(sm,role)
local result = nil
for _, gunPart in pairs(sm:GetChildren()) do
if gunPart:IsA("BasePart") then
if gunPart.Name == "Bolt" then
if gunPart:FindFirstChild("BoltRole") then
if gunPart.BoltRole.Value == role then
result = gunPart
end
end
end
end
end
return result
end
function weldWeapon(player,weapon)
local weaponWelds = {}
local WeldCFrames = {}
local Type = weapon:FindFirstChild("Type")
if not Type then return end
if Type.Value == "Gun" or Type.Value == "Explosive" then
GunBuilders[player].Weapon = weapon
local Handle = weapon.HoldPart
for _, v in pairs(weapon:GetChildren()) do
if v:IsA("BasePart") and (not v:FindFirstChild("AttachmentJointRef")) then
if Utils.inList(v.Name,GunBuilders[player].WeldedParts) then
for _, v2 in pairs(v:GetChildren()) do
if v2:IsA("JointInstance") then
v2:Destroy()
end
end
end
v.Anchored = true;
end
end
for _, v in pairs(weapon:GetChildren()) do
if v:IsA("BasePart") then
if v.Name == "Camo" and v:FindFirstChildOfClass("Texture") then
for _, texture in pairs(v:GetChildren()) do
if texture:IsA("Texture") then
texture.Texture = weapon.CamoId.Value
end
end
end
if v ~= Handle and (not v:FindFirstChild("AttachmentJointRef")) and (GunBuilders[player]:isSpecialPart(v)) then
v.Anchored = true
v.CanCollide = false
print("WeldWeap")
WeldCFrames[v] = Handle.CFrame:toObjectSpace(v.CFrame)
local Weld = Instance.new("Weld")
Weld.Name = "MainWeld"
Weld.Part0 = Handle
Weld.Part1 = v
Weld.C0 = WeldCFrames[v]
if weapon.GunType.Value == "Revolver" and v.Name:sub(1,3) == "Mag" and not v.Name:find("Case") then
Weld:Destroy()
local MagWeld = Instance.new("Weld")
MagWeld.Part0 = weapon.Carousel
MagWeld.Part1 = v
MagWeld.C0 = weapon.Carousel.CFrame:toObjectSpace(v.CFrame)
MagWeld.C1 = CF()
MagWeld.Parent = weapon.Carousel
v.Anchored = false
else
Weld.Parent = Handle
weaponWelds[v] = Weld
v.Anchored = false
end
if string.sub(v.Name, 1, 3) == "Mag" then
if (not v:FindFirstChild("magTrans")) then
local magTrans = Instance.new("NumberValue")
magTrans.Name = "magTrans"
magTrans.Value = v.Transparency
magTrans.Parent = v
end
end
elseif v:IsA("BasePart") and v.Name == "Bolt" and v:FindFirstChild("BoltRole") then
if v:FindFirstChild("SightWeld") then
v.SightWeld:Destroy()
end
v.CanCollide = false
addBolt(player,v,weapon.SlidePart)
elseif v:IsA("BasePart") and v.Name == "BoltPart" and v:FindFirstChild("BoltRole") then
v.CanCollide = false
local weld = Instance.new("Weld")
weld.Name = "BoltAttachment"
weld.Part0 = findBolt(weapon,v.BoltRole.Value)
weld.Part1 = v
weld.C0 = findBolt(weapon,v.BoltRole.Value).CFrame:toObjectSpace(v.CFrame)
weld.Parent = findBolt(weapon,v.BoltRole.Value)
v.Anchored = false
elseif v:IsA("BasePart") and weapon.GunType.Value == "LMG" and (v.Name == "LidPart" or v.Name == "LidPartMainSight") then
v.Anchored = true
local w = Instance.new("Weld")
w.Name = "LidAttachment"
w.Part0 = weapon.Lid
w.Part1 = v
w.C0 = weapon.Lid.CFrame:toObjectSpace(v.CFrame)
w.Parent = weapon.Lid
v.Anchored = false
elseif v:IsA("BasePart") and weapon.GunType.Value == "LMG" and v.Name == "LidPartMainReticle" then
v.Anchored = true
local w = Instance.new("Weld")
w.Name = "LidAttachment"
w.Part0 = weapon.LidPartMainSight
w.Part1 = v
w.C0 = weapon.LidPartMainSight.CFrame:toObjectSpace(v.CFrame)
w.Parent = weapon.LidPartMainSight
v.Anchored = false
elseif v:IsA("BasePart") and weapon.GunType.Value == "LMG" and v.Name == "LidHinge" then
local HingeWeld = Instance.new("Motor6D")
HingeWeld.Name = "LidHinge"
HingeWeld.Part0 = weapon.LidEffector
HingeWeld.Part1 = v
HingeWeld.C0 = weapon.LidEffector.CFrame:toObjectSpace(v.CFrame)
HingeWeld.C1 = CF()
HingeWeld.Parent = HingeWeld.Part0
v.Anchored = false
elseif v:IsA("BasePart") and weapon.GunType.Value == "LMG" and v.Name == "Lid" then
local HingeWeld1 = Instance.new("Weld")
HingeWeld1.Name = "LidAttachment"
HingeWeld1.Part0 = weapon.LidHinge
HingeWeld1.Part1 = v
HingeWeld1.C0 = weapon.LidHinge.CFrame:toObjectSpace(v.CFrame)
HingeWeld1.C1 = CF()
HingeWeld1.Parent = HingeWeld1.Part0
v.Anchored = false
elseif v:IsA("BasePart") and v.Name == "MainSight" then
if GunBuilders[player].S.boltSettings.weldMainSight then
local sightWeld = Instance.new("Weld")
sightWeld.Name = "SightWeld"
sightWeld.Part0 = findBolt(weapon,"Main")
sightWeld.Part1 = v
sightWeld.C0 = findBolt(weapon,"Main").CFrame:toObjectSpace(v.CFrame)
sightWeld.C1 = CF()
sightWeld.Parent = findBolt(weapon,"Main")
v.Anchored = false
end
elseif v:IsA("BasePart") and weapon.GunType.Value == "Revolver" and v.Name == "RevolverHinge" then
local RevolverHingeMotor = Instance.new("Motor6D")
RevolverHingeMotor.Name = "RevolverHinge"
RevolverHingeMotor.Part0 = weapon.RHPart
RevolverHingeMotor.Part1 = v
RevolverHingeMotor.C0 = weapon.RHPart.CFrame:toObjectSpace(v.CFrame)
RevolverHingeMotor.C1 = CFrame.new()
RevolverHingeMotor.Parent = weapon.RHPart
v.Anchored = false
elseif v:IsA("BasePart") and weapon.GunType.Value == "Revolver" and v.Name == "RevolverBarrel" then
local RevolverBarrelWeld = Instance.new("Motor6D")
RevolverBarrelWeld.Name = "BarrelAttachment"
RevolverBarrelWeld.Part0 = weapon.RevolverHinge
RevolverBarrelWeld.Part1 = v
RevolverBarrelWeld.C0 = weapon.RevolverHinge.CFrame:toObjectSpace(v.CFrame)
RevolverBarrelWeld.Parent = weapon.RevolverHinge
v.Anchored = false
elseif v:IsA("BasePart") and weapon.GunType.Value == "Revolver" and v.Name == "Carousel" then
local RevolverCarouselMotor = Instance.new("Motor6D")
RevolverCarouselMotor.Name = "CarouselMotor"
RevolverCarouselMotor.Part0 = weapon.RHPart
RevolverCarouselMotor.Part1 = v
RevolverCarouselMotor.C0 = weapon.RHPart.CFrame:toObjectSpace(v.CFrame)
RevolverCarouselMotor.C1 = CFrame.new()
RevolverCarouselMotor.Parent = weapon.RHPart
v.Anchored = false
elseif v:IsA("BasePart") and weapon.GunType.Value == "Shotgun" and GunBuilders[player].S.actionType == "Pump" and v.Name == "Pump" then
local PumpSlide = Instance.new("Motor6D")
PumpSlide.Name = "PumpSlide"
PumpSlide.Part0 = weapon.PumpPart
PumpSlide.Part1 = v
PumpSlide.C0 = weapon.PumpPart.CFrame:toObjectSpace(v.CFrame)
PumpSlide.C1 = CF()
PumpSlide.Parent = weapon.PumpPart
v.Anchored = false
elseif v:IsA("BasePart") and v.Name == "Stock" and GunBuilders[player].S.hasFoldingStock then
local weld = Instance.new("Weld")
weld.Name = "StockWeld"
weld.Part0 = weapon.StockMain
weld.Part1 = v
weld.C0 = weapon.StockMain.CFrame:toObjectSpace(v.CFrame)
weld.Parent = weapon.StockMain
v.Anchored = false
elseif v:IsA("BasePart") and v.Name == "StockMain" and GunBuilders[player].S.hasFoldingStock then
local StockHingeWeld = Instance.new("Motor6D")
StockHingeWeld.Name = "StockFoldHinge"
StockHingeWeld.Part0 = weapon.StockHinge
StockHingeWeld.Part1 = v
StockHingeWeld.C0 = weapon.StockHinge.CFrame:toObjectSpace(v.CFrame)
StockHingeWeld.C1 = CF()
StockHingeWeld.Parent = weapon.StockHinge
v.Anchored = false
elseif v:IsA("BasePart") and weapon:FindFirstChild("BipodMain") and v.Name == "BipodMountPart" then
local MountWeld = Instance.new("Motor6D")
MountWeld.Name = "MountWeld"
MountWeld.Part0 = weapon.BipodMain
MountWeld.Part1 = v
MountWeld.C0 = weapon.BipodMain.CFrame:toObjectSpace(v.CFrame)
MountWeld.Parent = MountWeld.Part0
v.Anchored = false
elseif weapon:FindFirstChild("BipodMain") and v.Name == "BipodYHinge" then
local YHinge = Instance.new("Motor6D")
YHinge.Name = "BipodVertHinge"
YHinge.Part0 = weapon.BipodMain
YHinge.Part1 = v
YHinge.C0 = weapon.BipodMain.CFrame:toObjectSpace(v.CFrame)
YHinge.Parent = YHinge.Part0
v.Anchored = false
elseif v:IsA("BasePart") and weapon:FindFirstChild("BipodMain") and v.Name == "LeftBipodPart" then
local lBW = Instance.new("Weld")
lBW.Name = "BipodLegWeld"
lBW.Part0 = weapon.LeftBipodHinge
lBW.Part1 = v
lBW.C0 = weapon.LeftBipodHinge.CFrame:toObjectSpace(v.CFrame)
lBW.Parent = lBW.Part0
v.Anchored = false
elseif v:IsA("BasePart") and weapon:FindFirstChild("BipodMain") and v.Name == "BipodLeftHinge" then
local XWeldLeft = Instance.new("Weld")
XWeldLeft.Name = "BipodLeftWeld"
XWeldLeft.Part0 = weapon.BipodYHinge
XWeldLeft.Part1 = v
XWeldLeft.C0 = weapon.BipodYHinge.CFrame:toObjectSpace(v.CFrame)
XWeldLeft.C1 = CFANG(RAD(-0),0,0)
XWeldLeft.Parent = weapon.BipodYHinge
elseif v:IsA("BasePart") and weapon:FindFirstChild("BipodMain") and v.Name == "RightBipodPart" then
local lBW = Instance.new("Weld")
lBW.Name = "BipodLegWeld"
lBW.Part0 = weapon.RightBipodHinge
lBW.Part1 = v
lBW.C0 = weapon.RightBipodHinge.CFrame:toObjectSpace(v.CFrame)
lBW.Parent = lBW.Part0
v.Anchored = false
elseif v:IsA("BasePart") and weapon:FindFirstChild("BipodMain") and v.Name == "RightBipodHinge" then
local XWeldRight = Instance.new("Weld")
XWeldRight.Name = "BipodRightWeld"
XWeldRight.Part0 = weapon.BipodYHinge
XWeldRight.Part1 = v
XWeldRight.C0 = weapon.BipodYHinge.CFrame:toObjectSpace(v.CFrame)
XWeldRight.C1 = CFANG(RAD(GunBuilders[player].S.bipodspread and GunBuilders[player].S.bipodspread or -0),0,0)
XWeldRight.Parent = weapon.BipodYHinge
v.Anchored =false
end
end
end
elseif Type.Value == "Grenade" then
end
end
function sheatheGun(Torso,weapon,player,slot)
if Torso and weapon then
if sheatheModels[player][slot] then
sheatheModels[player][slot]:Destroy()
end
local S = require(weapon.SETTINGS)
local guntype = S.sheatheSettings.gunProfile
local weldmode = S.sheatheSettings.weldProfile
local distance = S.sheatheSettings.CFrameSettings.position
local rotation = S.sheatheSettings.CFrameSettings.rotation
local y = S.sheatheSettings.CFrameSettings.y
local x = S.sheatheSettings.CFrameSettings.x
sheatheModels[player][slot] = Instance.new("Model")
sheatheModels[player][slot].Name = weapon.Name .. "_Holster"
local gunRef = Instance.new("ObjectValue")
gunRef.Name = "Item"
gunRef.Value = weapon
gunRef.Parent = sheatheModels[player][slot]
if weapon.Type.Value == "Gun" or weapon.Type.Value == "Grenade" then
for _, v in pairs(weapon:GetChildren()) do
if v:IsA("BasePart") and (not v:FindFirstChild("AttachmentJointRef")) then
print(v.Name)
if inList(v.Name,GunBuilders[player].WeldedParts) then
for _, v2 in pairs(v:GetChildren()) do
if v2:IsA("JointInstance") and (not v2.Part1:FindFirstChild("AttachmentJointRef")) then
v2:Destroy()
end
end
end
v.Anchored = true
end
end
end
for _, part in pairs(weapon:GetChildren()) do
if part:IsA("BasePart") and part ~= weapon.HoldPart then
local part2 = part:Clone()
part2.Parent = sheatheModels[player][slot]
part2.CanCollide = false
elseif part == weapon.HoldPart then
local handle2 = part:Clone()
handle2:BreakJoints()
handle2.Parent = sheatheModels[player][slot]
sheatheModels[player][slot].PrimaryPart = handle2
end
end
for _, Obj in pairs(sheatheModels[player][slot]:GetChildren()) do
if Obj:IsA("BasePart") and Obj ~= sheatheModels[player][slot].HoldPart then
Obj.Anchored = true
local Weld = Instance.new("Weld")
Weld.Name = "MainWeld"
Weld.Part0 = sheatheModels[player][slot].HoldPart
Weld.Part1 = Obj
Weld.C0 = sheatheModels[player][slot].HoldPart.CFrame:toObjectSpace(Obj.CFrame)
Weld.Parent = sheatheModels[player][slot].HoldPart
Obj.Anchored = false
Obj.CanCollide = false
end
end
sheatheModels[player][slot].PrimaryPart.CFrame = sheatheWelds[player][slot].Part0.CFrame
sheatheWelds[player][slot].Part1 = sheatheModels[player][slot].PrimaryPart
if guntype == 1 then
if weldmode == 1 then
sheatheWelds[player][slot].C1 = CF(distance *-1, 0.25 +y, -0.75 +x *-1) * CFANG(RAD(rotation *-1), (math.pi / 2), 0)
elseif weldmode == 2 then
sheatheWelds[player][slot].C1 = CF(distance, 0.25 +y, -0.75 +x *-1) * CFANG(RAD(rotation *-1), (math.pi / 2 ) *-1, 0)
elseif weldmode == 3 then
sheatheWelds[player][slot].C1 = CF(distance *-1, -0.1+y, 0.2 +x *-1) * CFANG(RAD(rotation), (math.pi / 2), -1.5)
elseif weldmode == 4 then
sheatheWelds[player][slot].C1 = CF(distance, 0.25+y, -0.75 +x *-1) * CFANG(RAD(rotation), (math.pi / 2 +rotation) *-1.1, 1)
end
elseif guntype == 2 then
if weldmode == 1 then
sheatheWelds[player][slot].C1 = CF(distance *-1, 0.25+y, -0.5 +x *-1) * CFANG(RAD(rotation *-1), math.pi / 2, 0)
elseif weldmode == 2 then
sheatheWelds[player][slot].C1 = CF(distance, 0.25 +y, -0.5 +x *-1) * CFANG(RAD(rotation *-1), math.pi / 2 *-1, 0)
elseif weldmode == 3 then
sheatheWelds[player][slot].C1 = CF(distance *-1, 0.25 +y, -0.5 +x *-1) * CFANG(RAD(rotation), math.pi / 2, 0)
elseif weldmode == 4 then
sheatheWelds[player][slot].C1 = CF(distance, 0.25 +y, -0.5 +x *-1) * CFANG(RAD(rotation), math.pi / 2 *-1, 0)
end
elseif guntype == 3 then
if weldmode == 1 then
sheatheWelds[player][slot].C1 = CF(distance *-1, 0 +y, -0.25 +x *-1) * CFANG(math.pi / 2, 0, 0)
elseif weldmode == 2 then
sheatheWelds[player][slot].C1 = CF(distance, 0 +y, -0.25 +x *-1) * CFANG(math.pi / 2, 0, 0)
elseif weldmode == 3 then
sheatheWelds[player][slot].C1 = CF(distance *-1, 0 +y, 0.25 +x) * CFANG(math.pi / 2 , math.pi / 2, 0)
elseif weldmode == 4 then
sheatheWelds[player][slot].C1 = CF(distance, 0 +y, 0.25 +x) * CFANG(math.pi / 2 , math.pi / 2 *-1, 0)
end
end
sheatheModels[player][slot].Parent = player.Character
sheatheModels[player][slot].HoldPart.Anchored = false
sheatheModels[player][slot].HoldPart.CanCollide = false
end
end
function makeSheatheWeld(weapon,plr,Torso,LLeg,RLeg)
local SW = Instance.new("Motor6D")
SW.Name = "SheatheWeld"
local S = require(weapon.SETTINGS)
local guntype = S.sheatheSettings.gunProfile
local weldmode = S.sheatheSettings.weldProfile
local distance = S.sheatheSettings.CFrameSettings.position
local rotation = S.sheatheSettings.CFrameSettings.rotation
local y = S.sheatheSettings.CFrameSettings.y
local x = S.sheatheSettings.CFrameSettings.x
local SPPart
if guntype == 1 or guntype == 2 then
SW.Part0 = Torso
SPPart = Torso
elseif guntype == 3 or guntype == 4 then
if weldmode == 1 then
SW.Part0 = RLeg
SPPart = RLeg
elseif weldmode == 2 then
SW.Part0 = LLeg
SPPart = LLeg
elseif weldmode == 3 or weldmode == 4 then
SW.Part0 = Torso
SPPart = Torso
end
end
SW.Parent = SPPart
return SW
end
function unSheatheGun(Torso,player,weapon,slot)
if Torso then
if sheatheModels[player][slot] then
sheatheWelds[player][slot].Part1 = nil
end
end
if sheatheModels[player][slot] then
sheatheModels[player][slot]:ClearAllChildren()
weldWeapon(player,weapon)
end
end
game.Players.PlayerAdded:connect(function(plr)
local InventoryFolder = Instance.new("Folder")
InventoryFolder.Name = "Inventory"
InventoryFolder.Parent = plr
local CFolder = Instance.new("Folder")
CFolder.Name = "Carry"
CFolder.Parent = plr
local PickupsFolder = Instance.new("Folder")
PickupsFolder.Name = "Pickups"
PickupsFolder.Parent = plr
saveGameContainers[plr] = SaveGameService:CreateSaveGameContainer(plr)
AchievementCache[plr] = {}
for _, ach in pairs(AchievementList) do
AchievementCache[plr][#AchievementCache[plr] + 1] = ach
AchievementCache[plr][#AchievementCache[plr]]:SetPlr(plr)
end
for _, ach in pairs(AchievementCache[plr]) do
for _, achName in pairs(saveGameContainers[plr].Achievements) do
if ach.Name == achName then
ach.Completed = true
end
end
end
Grips[plr] = {
Right = nil;
Left = nil;
}
PlayerLoadouts[plr] = InventoryService.LoadoutClass.new("Main",nil,nil,nil,nil,nil)
AttachmentLibraries[plr] = {}
for _, itemName in pairs({
"VSS Vintorez";
"AKM";
"AR-10";
"F2000";
"G3";
"M60";
"M249";
"M64V5";
"M64V5A1";
"M16";
"MAK-47";
"MTAR-21";
"LSCAR";
"CM4";
"MP5";
"DEAGLE 50";
"SCAR-L";
"L96";
"SPAS-12";
"M4";
"RPK";
"M14";
"M72";
"SMG380";
"AKS-74U";
"M1911";
"SG380";
"M9";
"Makarov";
"LSCAR-PG";
"LSCAR-OP";
"P90";
"AT4";
"C9A2";
"Steyr Scout";
"Judge";
"AmmoBox (M43)";
"AS Val";
"AN-94";
"Dragunov SVD";
"AS50";
"RTA-SR";
"Five-seveN";
"R79U";
"SN-49C";
"M1014";
--"PKM";
}) do
local item = ItemStorage:GetNewItem(itemName)
if item then
item = item:Clone()
local ID = RNG:NextInteger(1,1e8);
game.CollectionService:AddTag(item,ID)
item.Parent = InventoryFolder
end
AttachmentLibraries[plr][item.Name] = {
Optics = "";
Barrel = "";
Underbarrel = "";
Other = "";
};
end
local nade = ItemStorage:GetNewItem("Frag")
if nade then
nade = nade:Clone()
nade.Parent = plr.Carry
end
GunBuilders[plr] = Utils.CreateGameObject("WeapBuilder","Gun",{
"SlidePart";
"PumpPart";
"LidHinge";
"Lid";
"Bolt";
"LidEffector";
"Carousel";
"RevolverHinge";
"RHPart";
"StockMain";
"StockHinge";
"BipodMain";
"BipodYHinge";
"LeftBipodHinge";
"RightBipodHinge";
"HoldPart";
})
BoltWelds[plr] = {}
sheatheWelds[plr] = {
Primary = nil;
Secondary = nil;
Explosive = nil;
Gadget = nil;
Melee = nil;
};
sheatheModels[plr] = {
Primary = nil;
Secondary = nil;
Explosive = nil;
Gadget = nil;
Melee = nil;
}
KillService:RegisterPlayer(plr,saveGameContainers[plr].MissionData.Kills,saveGameContainers[plr].MissionData.HeadShots)
game.CollectionService:AddTag(plr,plr.Name)
plr.CharacterAdded:connect(function(c)
c:WaitForChild("Humanoid",200)
require(plr.Team.TeamOutfit):Apply(c)
c.ChildAdded:connect(function(item)
if item:IsA("Model") then
if item:FindFirstChild("Type") then
if item.Type.Value == "Grenade" then
local handle = item:FindFirstChild("HoldPart")
for _, v in pairs(item:GetChildren()) do
if v:IsA("BasePart") and v ~= handle then
local w = Instance.new("Motor6D")
w.Name = "GrenadeWeld"
w.Part0 = handle
w.Part1 = v
w.C0 = handle.CFrame:toObjectSpace(v.CFrame)
w.C1 = CFrame.new()
w.Parent = handle
v.Anchored = false
end
end
handle.Anchored = false
elseif item.Type.Value == "Gun" or item.Type.Value == "Explosive" then
local function getSlot(weapon)
if game.CollectionService:HasTag(weapon,"Primary") then
return "Primary"
elseif game.CollectionService:HasTag(weapon,"Secondary") then
return "Secondary"
elseif game.CollectionService:HasTag(weapon,"Explosive") then
return "Explosive"
end
end
local itemSettings = require(item.SETTINGS)
unSheatheGun(c.Torso,plr,item,getSlot(item))
item.HoldPart.Anchored = false
item.HoldPart.CanCollide = true
local OpticsAttachment = BindableService.fetch("GetAttachmentSlot",plr,item.Name,"Optics")
if (#OpticsAttachment > 0) then
item.BlackScope.Value = BindableService.fetch("IsAttachmentBlackScoped",OpticsAttachment)
item.FOV.Value = BindableService.fetch("GetAttachmentFOV",OpticsAttachment) or itemSettings.aimSettings.InFOV
else
item.BlackScope.Value = itemSettings.guiScope
item.FOV.Value = itemSettings.aimSettings.InFOV
item.ScopeId.Value = itemSettings.scopeSettings.Id or ""
end
end
end
end
end)
c.ChildRemoved:connect(function(item)
if item:IsA("Model") then
if item:FindFirstChild("Type") then
if item.Type.Value == "Grenade" then
item:BreakJoints()
local handle = item:FindFirstChild("HoldPart")
for _, v in pairs(item:GetChildren()) do
if v:IsA("BasePart") then
v.Anchored = true
end
end
handle.Anchored = false
elseif item.Type.Value == "Gun" or item.Type.Value == "Explosive" then
local function getSlot(weapon,plr)
if weapon == PlayerLoadouts[plr].Primary then
return "Primary"
elseif weapon == PlayerLoadouts[plr].Secondary then
return "Secondary"
elseif weapon == PlayerLoadouts[plr].Explosive then
return "Explosive"
end
end
sheatheGun(c.Torso,plr,item,getSlot(item,plr))
end
end
end
end)
if currentRound then
RemoteService.bounce("Client","UpdateScore",game.Teams.BloxxerInsurgency.Name,currentRound.Scores[game.Teams.BloxxerInsurgency])
RemoteService.bounce("Client","UpdateScore",game.Teams.RobloxianRepublic.Name,currentRound.Scores[game.Teams.RobloxianRepublic])
end
c.Humanoid.MaxHealth = saveGameContainers[plr].MaxHP
if currentRound then
local cSpawn = currentRound:GetSpawnCFrame(plr)
if cSpawn then
AntiSpeed.Set(plr,false)
c:SetPrimaryPartCFrame(cSpawn)
AntiSpeed.Set(plr,true)
end
end
sheatheWelds[plr]["Primary"] = makeSheatheWeld(PlayerLoadouts[plr].Primary,plr,c.Torso,c:FindFirstChild("Left Leg"),c:FindFirstChild("Right Leg"))
sheatheWelds[plr]["Secondary"] = makeSheatheWeld(PlayerLoadouts[plr].Secondary,plr,c.Torso,c:FindFirstChild("Left Leg"),c:FindFirstChild("Right Leg"))
sheatheWelds[plr]["Explosive"] = makeSheatheWeld(PlayerLoadouts[plr].Explosive,plr,c.Torso,c:FindFirstChild("Left Leg"),c:FindFirstChild("Right Leg"))
sheatheGun(c.Torso,PlayerLoadouts[plr].Primary,plr,"Primary")
sheatheGun(c.Torso,PlayerLoadouts[plr].Secondary,plr,"Secondary")
sheatheGun(c.Torso,PlayerLoadouts[plr].Explosive,plr,"Explosive")
wait(0.5)
PlayerLoadouts[plr]("equip",plr)
PlayerLoadouts[plr].Primary.Parent = c
end)
end)
game.Players.PlayerRemoving:connect(function(plr)
saveGameContainers[plr]("Get","Save")
saveGameContainers[plr] = nil;
AchievementCache[plr] = nil;
end)
RemoteService.listen("Server","Fetch","GetPlayerBalance",function(plr)
return saveGameContainers[plr].guncoins;
end)
RemoteService.listen("Server","Fetch","GetBoltWelds",function(player)
return BoltWelds[player];
end)
RemoteService.listen("Server","Fetch","Deploy",function(plr)
if workspace:FindFirstChild(plr.Name) then return false end
if CurrentMap and currentRound and currentRound.GameReady and PlayerLoadouts[plr].Primary then
plr:LoadCharacter(true)
return true
else
return false
end
end)
local function createFakeArm(plr,S,...)
local args = {...}
local armType = args[1]
local LArm = args[2]
local RArm = args[3]
local armModelParent = args[4]
local armName = armType .. " Arm"
local armModel = game.ReplicatedStorage.ArmStorage:FindFirstChild(armName):Clone()
armModel.Name = "armModel"
local Arm = (armType == "Left" and LArm or RArm):Clone()
Arm.Size = armModel.Arm.Size
if Arm:FindFirstChild("RightGrip") then
Arm.RightGrip:Destroy()
end
armModel:SetPrimaryPartCFrame(Arm.CFrame)
armModel.Arm:Destroy()
Arm.BrickColor = (S.fakeArmSettings.realBodyColor and (armType == "Left" and LArm.BrickColor or RArm.BrickColor) or S.fakeArmSettings.Color)
Arm.Transparency = S.fakeArmSettings.Transparency
Arm.Name = armName
Arm.CanCollide = false
Arm.Parent = armModelParent
for _, part in pairs(armModel:GetChildren()) do
if part:IsA("BasePart") then
local armWeld = Instance.new("Weld")
armWeld.Name = "ArmWeld"
armWeld.Part0 = Arm
armWeld.Part1 = part
armWeld.C0 = Arm.CFrame:toObjectSpace(part.CFrame)
armWeld.Parent = Arm
end
end
if _G.Outfits then
local outfit = require(plr.Team.TeamOutfit)
if not outfit then
return armModel
end
for _, part in pairs(armModel:GetChildren()) do
if part:IsA("BasePart") then
if part.Name:find("BackArm") then
part.Color = outfit.ArmSkin[1]
elseif part.Name == "GlovePart" then
part.Color = outfit.ArmSkin[2]
end
end
end
end
return armModel
end
RemoteService.listen("Server","Fetch","MakeViewModel",function(player,S,Item,Vars)
local armModel = OBJ("Model")
armModel.Parent = Vars.playerFolder
local fakeLArm = createFakeArm(player,S,"Left",Vars.LArm:Clone(),Vars.RArm:Clone(),armModel)
fakeLArm.Parent = armModel
Vars.LArm.Transparency = 1
Vars.RArm.Transparency = 1
local fakeLWeld = OBJ("Weld")
fakeLWeld.Name = "FLWeld"
fakeLWeld.Part0 = armModel:FindFirstChild(Vars.LArm.Name)
fakeLWeld.Part1 = Vars.LArm
fakeLWeld.Parent = armModel:FindFirstChild(Vars.LArm.Name)
local fakeRArm = createFakeArm(player,S,"Right",Vars.LArm:Clone(),Vars.RArm:Clone(),armModel)
fakeRArm.Parent = armModel
local fakeRWeld = OBJ("Weld")
fakeRWeld.Name = "FRWeld"
fakeRWeld.Part0 = armModel:FindFirstChild(Vars.RArm.Name)
fakeRWeld.Part1 = Vars.RArm
fakeRWeld.Parent = armModel:FindFirstChild(Vars.RArm.Name)
local gIgnoreHum = OBJ("Humanoid")
gIgnoreHum.Parent = armModel
if S.fakeArmSettings.characterMeshes then
for _,Obj in pairs(Item.Parent:GetChildren()) do
if Obj:IsA("CharacterMesh") then
Obj:Clone().Parent = armModel
end
end
end
for _,Obj in pairs(Item.Parent:GetChildren()) do
if Obj:IsA("Shirt") then
Obj:Clone().Parent = armModel
end
end
return armModel
end)
RemoteService.listen("Server","Send","SetJointC0",function(player,Joint,JC0)
if Joint.Part0:GetNetworkOwner() == player then Joint.C0 = JC0 end
end)
RemoteService.listen("Server","Send","SetJointC1",function(player,Joint,JC1)
if Joint.Part1:GetNetworkOwner() == player then Joint.C1 = JC1 end
end)
RemoteService.listen("Server","Send","SetAJointC0",function(player,Joint,JC0)
if Joint.Part0:GetNetworkOwner() == player and Joint.Name == "animWeld" then Joint.C0 = JC0 end
end)
RemoteService.listen("Server","Send","SetAJointC1",function(player,Joint,JC1)
if Joint.Part1:GetNetworkOwner() == player and Joint.Name == "animWeld" then Joint.C1 = JC1 end
end)
RemoteService.listen ("Server","Send","DiscardNade",function(player,nade)
if nade then
nade.Parent = player.Carry
nade:Destroy()
end
end)
RemoteService.listen("Server","Send","ResetViewModel",function(player,Vars)
if Vars.gunIgnore then
Vars.gunIgnore:Destroy()
gunIgnores[player] = nil;
animWelds[player] = nil;
end
if Vars.Shoulders then
if Vars.LArm and Vars.RArm then
Vars.Shoulders.Right.Part1 = Vars.RArm
Vars.Shoulders.Left.Part1 = Vars.LArm
end
end
if Vars.Grips then
for i, grip in pairs(Vars.Grips) do
grip:Destroy()
Grips[player] = {
Left = nil;
Right = nil;
};
end
end
end)
RemoteService.listen("Server","Fetch","InitPlayerModel",function(player,Item,Vars,S)
local gunIgnore = OBJ("Model")
gunIgnore.Name = "gunIgnore_"..player.Name
gunIgnore.Parent = workspace.ignoreModel
local torso = Vars.Torso
local playerFolder = OBJ("Model")
playerFolder.Name = "playerFolder"
playerFolder.Parent = gunIgnore
Vars.Humanoid.AutoRotate = false
Vars.Shoulders.Right.Part1 = nil
Vars.Shoulders.Left.Part1 = nil
local headBase = Instance.new("Part")
headBase.Transparency = 1
headBase.Name = "headBase"
headBase.CanCollide = false
headBase.FormFactor = Enum.FormFactor.Custom
headBase.Size = V3(0.2, 0.2, 0.2)
headBase.BottomSurface = Enum.SurfaceType.Smooth
headBase.TopSurface = Enum.SurfaceType.Smooth
headBase.Parent = playerFolder
headBase:SetNetworkOwner(player)
local headWeld = OBJ("Motor6D")
headWeld.Part0 = torso
headWeld.Part1 = headBase
headWeld.C0 = CF(0, 1.5, 0)
headWeld.Parent = torso
local headWeld2 = OBJ("Weld")
headWeld2.Part0 = headBase
headWeld2.Part1 = Vars.Head
headWeld2.Parent = headBase
local animBase = OBJ("Part")
animBase.Transparency = 1
animBase.Name = "animBase"
animBase.CanCollide = false
animBase.FormFactor = Enum.FormFactor.Custom
animBase.Size = V3(0.2, 0.2, 0.2)
animBase.BottomSurface = Enum.SurfaceType.Smooth
animBase.TopSurface = Enum.SurfaceType.Smooth
animBase.Parent = playerFolder
animBase:SetNetworkOwner(player)
local animWeld = Instance.new("Motor6D")
animWeld.Name = "animWeld"
animWeld.Part0 = animBase
animWeld.Part1 = headBase
animWeld.Parent = animBase
local armBase = OBJ("Part")
armBase.Transparency = 1
armBase.Name = "ArmBase"
armBase.CanCollide = false
armBase.FormFactor = Enum.FormFactor.Custom
armBase.Size = V3(0.2, 0.2, 0.2)
armBase.BottomSurface = Enum.SurfaceType.Smooth
armBase.TopSurface = Enum.SurfaceType.Smooth
armBase.Parent = playerFolder
armBase:SetNetworkOwner(player)
local ABWeld =Instance.new("Motor6D")
ABWeld.Part0 = armBase
ABWeld.Part1 = animBase
ABWeld.Name = "ABWeld"
ABWeld.Parent = armBase
local LArmBase = OBJ("Part")
LArmBase.Transparency = 1
LArmBase.Name = "LArmBase"
LArmBase.CanCollide = false
LArmBase.FormFactor = Enum.FormFactor.Custom
LArmBase.Size = V3(0.2, 0.2, 0.2)
LArmBase.BottomSurface = Enum.SurfaceType.Smooth
LArmBase.TopSurface = Enum.SurfaceType.Smooth
LArmBase.Parent = playerFolder
LArmBase:SetNetworkOwner(player)
local RArmBase = OBJ("Part")
RArmBase.Transparency = 1
RArmBase.Name = "RArmBase"
RArmBase.CanCollide = false
RArmBase.FormFactor = Enum.FormFactor.Custom
RArmBase.Size = V3(0.2, 0.2, 0.2)
RArmBase.BottomSurface = Enum.SurfaceType.Smooth
RArmBase.TopSurface = Enum.SurfaceType.Smooth
RArmBase.Parent = playerFolder
RArmBase:SetNetworkOwner(player)
local LWeld = Instance.new("Motor6D")
LWeld.Name = "LWeld"
LWeld.Part0 = armBase
LWeld.Part1 = LArmBase
LWeld.C0 = Vars.armC0[1]
LWeld.C1 = S.equipSettings.leftArmC1
LWeld.Parent = armBase
local RWeld = Instance.new("Motor6D")
RWeld.Name = "RWeld"
RWeld.Part0 = armBase
RWeld.Part1 = RArmBase
RWeld.C0 = Vars.armC0[2]
RWeld.C1 = S.equipSettings.rightArmC1
RWeld.Parent = armBase
local LWeld2 = Instance.new("Motor6D")
LWeld2.Name = "LWeld"
LWeld2.Part0 = LArmBase
LWeld2.Part1 = Vars.LArm
LWeld2.Parent = LArmBase
local RWeld2 = Instance.new("Motor6D")
RWeld2.Name = "RWeld"
RWeld2.Part0 = RArmBase
RWeld2.Part1 = Vars.RArm
RWeld2.Parent = RArmBase
local LLegWeld = Instance.new("Motor6D")
LLegWeld.Name = "LLegWeld"
LLegWeld.Part0 = torso
LLegWeld.C0 = CF(-0.5, -2, 0)
LLegWeld.Parent = torso
local RLegWeld = Instance.new("Motor6D")
RLegWeld.Name = "RLegWeld"
RLegWeld.Part0 = torso
RLegWeld.C0 = CF(0.5, -2, 0)
RLegWeld.Parent = torso
if Vars.RArm:FindFirstChild("RightGrip") then
Vars.RArm.RightGrip:Destroy()
end
Grips[player] = {
Right = nil;
Left = nil;
}
local Grip = Instance.new("Motor6D")
Grip.Name = "RightGrip"
Grip.Part0 = Vars.RArm
Grip.Part1 = Item.HoldPart
Grip.C0 = CF(0, -1, 0) * CFANG(-0.5 * math.pi, 0, 0)
Grip.C1 = S.equipSettings.GripC1
Grip.Parent = Vars.RArm
local Grip2 = Instance.new("Motor6D")
Grip2.Name = "LeftGrip"
Grip2.Parent = Vars.LArm
Grips[player].Left = Grip2;
Grips[player].Right = Grip
gunIgnores[player] = gunIgnore;
animWelds[player] = animWeld;
return gunIgnore, playerFolder, headWeld, headWeld2, armBase, animWeld, ABWeld, LWeld, RWeld, LWeld2, RWeld2, LLegWeld, RLegWeld, Grip, Grip2
end)
RemoteService.listen("Server","Fetch","GetPlayerAchievements",function(player)
local result = {}
for _, ach in pairs(AchievementCache[player]) do
result[#result+1] = ach:ToReplicatedAchievement()
end
return result
end)
BindableService.listen("Send","GiveAchievement",function(plr,achId)
AchievementCache[plr][achId]:Activate(saveGameContainers[plr])
end)
BindableService.listen("Fetch","GetCompletedAchievements",function(player)
local result = {}
for _, achievement in pairs(AchievementCache[player]) do
if achievement.Completed then
result[#result+1] = tostring(achievement)
end
end
return result
end)
InventoryService.startServer()
RemoteService.listen("Server","Send","ChangePrimaryWeapon",function(plr,weapon)
if weapon:IsDescendantOf(plr.Inventory) then
if PlayerLoadouts[plr].Primary then
PlayerLoadouts[plr].Primary:Destroy()
end
local w = weapon:Clone()
w.Parent = plr.Carry
PlayerLoadouts[plr].Primary = w
game.CollectionService:AddTag(w,"Primary")
RemoteService.send("Client",plr,"RegisterGun",w)
end
end)
local function isEnemy(plr,Human)
local Plyr2 = game.Players:GetPlayerFromCharacter(Human.Parent)
if (not Plyr2) then
if Human.Parent:FindFirstChild("BOT") then
return (require(Human.Parent.BOT).Team ~= plr.Team)
end
end
return (Plyr2 ~= nil and (Plyr2.Team ~= plr.Team or Plyr2.Neutral))
end
local numLerp = function(A, B, Alpha)
return A + (B - A) * Alpha
end
RemoteService.listen("Server","Send","MuzzleFlash",function(player,main)
RemoteService.bounceOthers("Client","MuzzleFlash",main)
end)
local function makeImpact(player, H, P, N, D, humanoidFound, S)
RemoteService.bounceOthers("Client",player,"ShowImpactFromPoint",H,P,N,D,humanoidFound,S.roundsPerMin)
end
RemoteService.listen("Server","Send","changeBoltC1",function(player,weapon,boltW,boltCF)
if weapon:FindFirstChild("SlidePart") then
if Utils.inList(boltW,BoltWelds[player]) then
boltW.C1 = boltCF
end
end
end)
RemoteService.listen("Server","Send","bulletImpact",makeImpact)
RemoteService.listen("Server","Send","VaultUp",function(player,Humanoid,HRP,hit)
local bp=Instance.new("BodyPosition")
bp.position=HRP.Position+HRP.CFrame.lookVector.unit*Humanoid.WalkSpeed/1.5+V3(0,2.5,0)
bp.maxForce=V3(5000000, 5000000, 5000000)
bp.P=4000
bp.Parent = HRP;
delay(0.,function()
bp:Destroy()
end)
end)
RemoteService.listen("Server","Send","ReplicateBullet",function(player,Direction,bCFrame,cartName)
RemoteService.bounceOthers("Client",player,"MakeBullet",Direction,bCFrame,cartName)
end)
local function tagHumanoid(Gun, humanoid, player, damage, previousHealth, headShot)
local tag
if humanoid.Health < 1 then
tag = DamageTag.new((game.Players:GetPlayerFromCharacter(humanoid.Parent) and game.CollectionService:GetTags(game.Players:GetPlayerFromCharacter(humanoid.Parent))[1] or game.CollectionService:GetTags(humanoid.Parent)[1]),damage,game.CollectionService:GetTags(Gun)[1],game.CollectionService:GetTags(player)[1],headShot)
else
tag = DamageTag.new((game.Players:GetPlayerFromCharacter(humanoid.Parent) and game.CollectionService:GetTags(game.Players:GetPlayerFromCharacter(humanoid.Parent))[1] or game.CollectionService:GetTags(humanoid.Parent)[1]),previousHealth,game.CollectionService:GetTags(Gun)[1],game.CollectionService:GetTags(player)[1],headShot)
end
tag:MarkEnemy(humanoid)
end
function Map(Val, fromLow, fromHigh, toLow, toHigh)
return (Val - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow
end
local function makeShockwave(player,Center, Radius, gunIgnore, S)
local Shockwave = OBJ("Part")
Shockwave.BrickColor = S.shockwaveSettings.Color
Shockwave.Material = Enum.Material.SmoothPlastic
Shockwave.Name = "Shockwave"
Shockwave.Anchored = true
Shockwave.CanCollide = false
Shockwave.FormFactor = Enum.FormFactor.Symmetric
Shockwave.Size = V3(1, 1, 1)
Shockwave.BottomSurface = Enum.SurfaceType.Smooth
Shockwave.TopSurface = Enum.SurfaceType.Smooth
local Mesh = OBJ("SpecialMesh")
Mesh.MeshType = Enum.MeshType.Sphere
Mesh.Scale = V3()
Mesh.Parent = Shockwave
Shockwave.Parent = gunIgnore
Shockwave.CFrame = CF(Center)
spawn(function()
local t0 = tick()
while true do
local Alpha = math.min((tick() - t0) / S.shockwaveSettings.Duration, 1)
local Scale = 2 * Radius * Alpha
Mesh.Scale = V3(Scale, Scale, Scale)
Shockwave.Transparency = Alpha
if Alpha == 1 then break end
wait(1/60)
end
Shockwave:Destroy()
end)
end
RemoteService.listen("Server","Send","Shockwave",makeShockwave)
local function makeShockwave(player,Center, Radius, gunIgnore, S)
local Shockwave = OBJ("Part")
Shockwave.BrickColor = S.shockwaveSettings.Color
Shockwave.Material = Enum.Material.SmoothPlastic
Shockwave.Name = "Shockwave"
Shockwave.Anchored = true
Shockwave.CanCollide = false
Shockwave.FormFactor = Enum.FormFactor.Symmetric
Shockwave.Size = V3(1, 1, 1)
Shockwave.BottomSurface = Enum.SurfaceType.Smooth
Shockwave.TopSurface = Enum.SurfaceType.Smooth
local Mesh = OBJ("SpecialMesh")
Mesh.MeshType = Enum.MeshType.Sphere
Mesh.Scale = V3()
Mesh.Parent = Shockwave
Shockwave.Parent = gunIgnore
Shockwave.CFrame = CF(Center)
spawn(function()
local t0 = tick()
while true do
local Alpha = math.min((tick() - t0) / S.shockwaveSettings.Duration, 1)
local Scale = 2 * Radius * Alpha
Mesh.Scale = V3(Scale, Scale, Scale)
Shockwave.Transparency = Alpha
if Alpha == 1 then break end
RS.Heartbeat:wait()
end
Shockwave:Destroy()
end)
end
function getBaseDamage(Gun,S,Dist)
local CurrentCartridge = Cartridges[S.bulletSettings.Cartridge]
if S.bulletSettings.RangeModifier then
CurrentCartridge.Range = CurrentCartridge.Range + S.bulletSettings.RangeModifier
end
if S.bulletSettings.VelocityModifier then
CurrentCartridge.Velocity = CurrentCartridge.Velocity + S.bulletSettings.VelocityModifier
end
if S.bulletSettings.AccelerationModifier then
CurrentCartridge.Acceleration = CurrentCartridge.Acceleration + S.bulletSettings.AccelerationModifier
end
if S.bulletSettings.SizeOverride then
CurrentCartridge.Size = S.bulletSettings.SizeOverride
end
if S.bulletSettings.ColorOverride then
CurrentCartridge.ColorOverride = S.bulletSettings.ColorOverride
end
CurrentCartridge:CalibrateSize()
local Cartridge = CurrentCartridge
local startDmg = Gun.MaxDmg.Value
local startDist = S.damageSettings.Start.Dist
local endDmg = Gun.MinDmg.Value
local endDist = S.damageSettings.End.Dist
return (
(
Dist < startDist * Cartridge.Range
) and startDmg or
(
Dist >= startDist * Cartridge.Range and
Dist < endDist * Cartridge.Range
) and numLerp(startDmg, endDmg, Map(Dist / Cartridge.Range, startDist, endDist, 0, 1)) or
(
Dist >= endDist * Cartridge.Range
) and endDmg
)
end
function Damage(plr,Humanoid,S,H, P, N, D, Dist, customIgnore, CartridgeName)
local hVal = S.damageSettings.Multipliers.Head
local cVal = S.damageSettings.Multipliers.Chest
local lVal = S.damageSettings.Multipliers.Limbs
local Cartridge = Cartridges[CartridgeName]
local CurrentCartridge = Cartridges[S.bulletSettings.Cartridge]
if S.bulletSettings.RangeModifier then
CurrentCartridge.Range = CurrentCartridge.Range + S.bulletSettings.RangeModifier
end
if S.bulletSettings.VelocityModifier then
CurrentCartridge.Velocity = CurrentCartridge.Velocity + S.bulletSettings.VelocityModifier
end
if S.bulletSettings.AccelerationModifier then
CurrentCartridge.Acceleration = CurrentCartridge.Acceleration + S.bulletSettings.AccelerationModifier
end
if S.bulletSettings.SizeOverride then
CurrentCartridge.Size = S.bulletSettings.SizeOverride
end
if S.bulletSettings.ColorOverride then
CurrentCartridge.ColorOverride = S.bulletSettings.ColorOverride
end
CurrentCartridge:CalibrateSize()
Cartridge = CurrentCartridge
if Humanoid.Health ~= 0 then
local hitHumanoid = nil
if not H then return end
if PlayerLoadouts[plr].CurrentWeapon then
local Gun = PlayerLoadouts[plr].CurrentWeapon
if H.Parent ~= nil then
if H.Parent:IsA("Accoutrement") or H.Parent:FindFirstChild("Middle") then
Utils.INSERT(customIgnore, H)
local newRay = RAY(P - D * 0.1, D * (Cartridge.Range - Dist + 0.1))
local newH, newP, newN = raycast(WS,newRay, customIgnore)
if newH then
hitHumanoid = Damage(plr, Humanoid, S, newH, newP, newN, D, Dist + (newP - P).magnitude, customIgnore, Cartridge)
end
else
hitHumanoid = H.Parent:FindFirstChildOfClass("Humanoid")
if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(plr,hitHumanoid) then
local chosenDamage = 0
local headShot = false
if H.Name == "Head" then
headShot = true
chosenDamage = RPGM.Combat.HeadshotOffset(getBaseDamage(Gun,S,Dist),RNG:NextNumber(Gun.HeadshotDamageMagnitude.Value/(2 - (hVal/BindableService.fetch("GetAttribute",plr,"Dexterity"))),Gun.HeadshotDamageMagnitude.Value)) * (hVal + 0.1)
elseif H.Name == "Torso" then
chosenDamage = (RPGM.Combat.RangedPower(BindableService.fetch("GetPlayerLevel",plr),BindableService.fetch("GetAttribute",plr,"Dexterity"),RNG:NextNumber(getBaseDamage(Gun,S,Dist)/(2 - (cVal/BindableService.fetch("GetAttribute",plr,"Dexterity"))),getBaseDamage(Gun,S,Dist))))
else
chosenDamage = (RPGM.Combat.RangedPower(BindableService.fetch("GetPlayerLevel",plr),BindableService.fetch("GetAttribute",plr,"Dexterity"),RNG:NextNumber(getBaseDamage(Gun,S,Dist)/(2 - (lVal/BindableService.fetch("GetAttribute",plr,"Dexterity"))),getBaseDamage(Gun,S,Dist))))
end
local sniperRand
if H.Name == "Head" and S.sniperDamage then
sniperRand = RNG:NextInteger(1,2)
chosenDamage = (sniperRand == 2 and hitHumanoid.Health or chosenDamage)
end
tagHumanoid(Gun,hitHumanoid,plr,chosenDamage,hitHumanoid.Health,headShot)
hitHumanoid:TakeDamage(chosenDamage)
RemoteService.send("Client",plr,"MarkHit")
end
end
return hitHumanoid
end
end
end
end
RemoteService.listen("Server","Send","FireExplosive",function(player,S,Gun,gunIgnore,H,P,N,bulletDirection,Ignore,Main)
if S.gunType.Explosive or Gun:FindFirstChild("GrenadeCaliber") then
if S.explosionSettings.soundId ~= "" then
local soundPart = OBJ("Part")
soundPart.Transparency = 1
soundPart.Anchored = true
soundPart.CanCollide = false
soundPart.Size = V3(1, 1, 1)
soundPart.CFrame = CF(P)
soundPart.Parent = gunIgnore
local Sound = OBJ("Sound")
Sound.Pitch = S.explosionSettings.Pitch
Sound.SoundId = S.explosionSettings.soundId
Sound.Volume = S.explosionSettings.Volume
Sound.Parent = soundPart
Sound:Play()
DS:AddItem(soundPart, Sound.TimeLength)
end
RemoteService.bounceOthers("Client",player,"ShowImpactFromPoint",H,P,N,bulletDirection,false,S.roundsPerMin)
makeShockwave(player, P, S.explosionSettings.Radius, gunIgnore, S)
local E = OBJ("Explosion")
E.BlastPressure = S.explosionSettings.Pressure
E.BlastRadius = S.explosionSettings.Radius
E.DestroyJointRadiusPercent = (S.explosionSettings.rangeBasedDamage and 0 or 1)
E.ExplosionType = S.explosionSettings.Type
E.Position = P
E.Hit:connect(function(Obj, Dist)
if Obj.Name == "Torso" and (not Obj:IsDescendantOf(player.Character)) then
if S.explosionSettings.rangeBasedDamage then
local Dir = (Obj.Position - P).unit
local expH, _ = workspace:FindPartOnRayWithIgnoreList(
RAY(P - Dir * 0.1, Dir * 999),
Ignore
)
local rayHitHuman = expH:IsDescendantOf(Obj.Parent)
if (S.explosionSettings.rayCastExplosions and rayHitHuman) or (not S.explosionSettings.rayCastExplosions) then
local hitHumanoid = Obj.Parent:FindFirstChildOfClass("Humanoid")
if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then
local newDamage = getBaseDamage((P - Main.CFrame.p).magnitude,Cartridges[Gun:FindFirstChild("GrenadeCaliber") and Gun.GrenadeCaliber.Value or S.bulletSettings.Cartridge])
tagHumanoid(hitHumanoid,player,newDamage,hitHumanoid.Health)
hitHumanoid:TakeDamage(newDamage)
RemoteService.send("Client",player,"MarkHit")
end
end
else
local hitHumanoid = Obj.Parent:FindFirstChildOfClass("Humanoid")
if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then
tagHumanoid(hitHumanoid,player,hitHumanoid.Health,hitHumanoid.Health)
RemoteService.send("Client",player,"MarkHit")
end
end
end
end)
E.Parent = game.Workspace
end
end)
RemoteService.listen("Server","Send","DoDamage",Damage)
RemoteService.listen("Server","Fetch","UseCode",function(plr,code)
code = code:lower()
print(saveGameContainers[plr].UsedCodes)
if Cheats[code] then
if not inList(code,saveGameContainers[plr].UsedCodes) then
Cheats[code](plr)
table.insert(saveGameContainers[plr].UsedCodes,#saveGameContainers[plr].UsedCodes+1,code)
return "Code redeemed."
else
return "Code already redeemed."
end
else
return "Invalid code"
end
end)
RemoteService.listen("Server","Fetch","GetLoadoutSlotDesc",function(plr)
return PlayerLoadouts[plr]:GetSlotList()
end)
RemoteService.listen("Server","Send","ChangeSecondaryWeapon",function(plr,weapon)
if weapon:IsDescendantOf(plr.Inventory) then
if PlayerLoadouts[plr].Secondary then
PlayerLoadouts[plr].Secondary:Destroy()
end
local w = weapon:Clone()
w.Parent = plr.Carry
PlayerLoadouts[plr].Secondary = w
game.CollectionService:AddTag(w,"Secondary")
RemoteService.send("Client",plr,"RegisterGun",w)
end
end)
RemoteService.listen("Server","Send","ChangeExplosiveWeapon",function(plr,weapon)
if weapon:IsDescendantOf(plr.Inventory) then
if PlayerLoadouts[plr].Explosive then
PlayerLoadouts[plr].Explosive:Destroy()
end
local w = weapon:Clone()
w.Parent = plr.Carry
PlayerLoadouts[plr].Explosive = w
game.CollectionService:AddTag(w,"Explosive")
RemoteService.send("Client",plr,"RegisterGun",w)
end
end)
RemoteService.listen("Server","Send","ChangeGadgetWeapon",function(plr,weapon)
if weapon:IsDescendantOf(plr.Inventory) then
if PlayerLoadouts[plr].Gadget then
PlayerLoadouts[plr].Gadget:Destroy()
end
local w = weapon:Clone()
w.Parent = plr.Carry
PlayerLoadouts[plr].Gadget = w
game.CollectionService:AddTag(w,"Gadget")
RemoteService.send("Client",plr,"RegisterGun",w)
end
end)
RemoteService.listen("Server","Send","ChangeMeleeWeapon",function(plr,weapon)
if weapon:IsDescendantOf(plr.Inventory) then
if PlayerLoadouts[plr].Melee then
PlayerLoadouts[plr].Melee:Destroy()
end
local w = weapon:Clone()
w.Parent = plr.Carry
PlayerLoadouts[plr].Melee = w
game.CollectionService:AddTag(w,"Melee")
RemoteService.send("Client",plr,"RegisterGun",w)
end
end)
RemoteService.listen("Server","Fetch","GetAttachmentEntry",function(player,weaponName)
return AttachmentLibraries[player][weaponName]
end)
RemoteService.listen("Server","Fetch","GetAttachmentSlot",function(player,weaponName,Slot)
return AttachmentLibraries[player][weaponName][Slot]
end)
BindableService.listen("Fetch","GetAttachmentSlot",function(player,weaponName,Slot)
return AttachmentLibraries[player][weaponName][Slot]
end)
BindableService.listen("Fetch","IsAttachmentBlackScoped",function(attachment)
local newAttachment = AttachmentsList[attachment]
if newAttachment then
return newAttachment.BlackScope
end
return false
end)
BindableService.listen("Fetch","GetAttachmentFOV",function(attachment)
local newAttachment = AttachmentsList[attachment]
if newAttachment and newAttachment.ExtraData.FOV then
return newAttachment.ExtraData.FOV
end
return nil
end)
BindableService.listen("Fetch","SwitchLoadoutItem",function(player,slot)
if player.Character then
player.Character.Humanoid:UnequipTools()
wait(2)
PlayerLoadouts[player]("equip",player)
return true
end
return false
end)
local function getWeaponInCarryById(plr,weapon)
local Carry = plr:WaitForChild("Carry",200)
local result = nil;
local ID = game.CollectionService:GetTags(weapon)[1]
for _, weapon2 in pairs(Carry:GetChildren()) do
local tag = game.CollectionService:GetTags(weapon2)[1]
if tag == ID then
result = weapon2
break;
end
end
return result
end
RemoteService.listen("Server","Fetch","GetWeaponFromCarryById",function(player,weapon)
return getWeaponInCarryById(player,weapon)
end)
RemoteService.listen("Server","Send","AttachToWeapon",function(player,attachmentName,weapon)
local newAttachment = AttachmentsList[attachmentName]
newAttachment:AddWeapon(weapon.Name,CFrame.new())
if (not weapon:FindFirstChild("Lid")) or newAttachment.Slot ~= "Optics" then
newAttachment:Apply(weapon,"HoldPart",player)
local weapon2 = getWeaponInCarryById(player,weapon)
if weapon2 then
newAttachment:Apply(weapon2,"HoldPart",player)
end
elseif (weapon:FindFirstChild("Lid") and newAttachment.Slot == "Optics") then
newAttachment:Apply(weapon,"Lid",player)
local weapon2 = getWeaponInCarryById(player,weapon)
if weapon2 then
newAttachment:Apply(weapon2,"Lid",player)
end
end
end)
BindableService.listen("Send","SetAttachmentSlot",function(player,weaponName,Slot,attachmentName)
if AttachmentsList[attachmentName] then
AttachmentLibraries[player][weaponName][Slot] = attachmentName
end
end)
RemoteService.listen("Server","Send","SetAttachmentSlot",function(player,weaponName,Slot,attachmentName)
if AttachmentsList[attachmentName] then
AttachmentLibraries[player][weaponName][Slot] = attachmentName
end
end)
BindableService.listen("Send","AddXP",function(plr,amount)
saveGameContainers[plr].XPOffset = amount
end)
BindableService.listen("Send","AddGunCoins",function(plr,amount)
saveGameContainers[plr].GunCoinsOffset = amount
end)
RemoteService.listen("Server","Fetch","IsPlayerCustomized",function(plr)
return saveGameContainers[plr].IsCustomized;
end)
BindableService.listen("Send","AddKill",function(killed,killer,points,...)
KillService:AddKill(killed,killer,points,...)
end)
BindableService.listen("Fetch","GetPlayerLevel",function(plr)
return saveGameContainers[plr] .level
end)
BindableService.listen("Fetch","GetAttribute",function(plr,attr)
return saveGameContainers[plr].Attributes[attr];
end)
RemoteService.listen("Server","Send","ChangeCamo",function(player,gun,camo)
local Camo = InventoryService.Camo.FromReplicatedCamo(camo)
Camo:Apply(gun)
CamoCache[game.CollectionService:GetTags(gun)[1]] = Camo
end)
RemoteService.listen("Server","Send","ClearCamo",function(player,gun)
local Camo = InventoryService.Camo.Clear(gun)
CamoCache[game.CollectionService:GetTags(gun)[1]] = nil
end)
RemoteService.listen("Server","Send","ClearAttachment",function(player,Gun,currentAttachment)
for _, part in pairs(Gun:GetChildren()) do
if part.Name == "MainSight" then
part.Transparency = 0
if part:FindFirstChildOfClass("Decal") then
part:FindFirstChildOfClass("Decal").Transparency = 1
end
elseif part.Name == "AimPart_Old" then
part.Name = "AimPart"
elseif part.Name == "Main_Old" then
part.Name = "Main"
elseif part:FindFirstChild("AttachmentJointRef") or game.CollectionService:HasTag(part,"Rail_" .. currentAttachment) then
part:Destroy()
end
end
end)
BindableService.listen("Fetch","GetItemCamoName",function(item)
if #game.CollectionService:GetTags(item) > 0 then
print(game.CollectionService:GetTags(item)[1])
print(CamoCache[game.CollectionService:GetTags(item)[1]])
if CamoCache[game.CollectionService:GetTags(item)[1]] and tonumber(game.CollectionService:GetTags(item)[1]) then
return CamoCache[game.CollectionService:GetTags(item)[1]].Title
end
end
return nil
end)
RemoteService.listen("Server","Fetch","GetWeaponCMode",function(plr,weaponType)
return saveGameContainers[plr].weaponcameramode(weaponType)
end)
RemoteService.listen("Server","Send","SetWeaponCMode",function(plr,weaponType, val)
if saveGameContainers[plr].weaponcameramode(weaponType) then
saveGameContainers[plr].weaponcameramode = {weaponType = weaponType;val = val}
end
end)
RemoteService.listen("Server","Fetch","GetAttribute",function(plr,attr)
return saveGameContainers[plr].Attributes[attr];
end)
RemoteService.listen("Server","Fetch","GetKeybinds",function(plr,platform,itemType)
return saveGameContainers[plr].Keybinds[itemType][platform];
end)
RemoteService.listen("Server","Fetch","GetPlayerLevelOther",function(plr,killer)
return saveGameContainers[killer].level;
end)
BindableService.listen("Fetch","GetKillerAttachments",function(killer)
local Primary = PlayerLoadouts[killer].Primary
if Primary then
return AttachmentLibraries[killer][Primary.Name].Optics, AttachmentLibraries[killer][Primary.Name].Barrel, AttachmentLibraries[killer][Primary.Name].Underbarrel
end
return nil,nil,nil
end)
RemoteService.listen("Server","Fetch","GetStamina",function(plr,statType)
if statType == "Reg" then
return saveGameContainers[plr].Stats.Stamina;
elseif statType == "Max" then
return saveGameContainers[plr].Stats.MaxStamina;
end
end)
RemoteService.listen("Server","Fetch","GetLoadoutItem",function(plr,index)
return PlayerLoadouts[plr].CurrentItems[index]
end)
BindableService.listen("Fetch","GetStamina",function(plr,statType)
if statType == "Reg" then
return saveGameContainers[plr].Stats.Stamina;
elseif statType == "Max" then
return saveGameContainers[plr].Stats.MaxStamina;
end
end)
BindableService.listen("Send","RegenStamina",function(plr)
saveGameContainers[plr]("Do","RegenStamina")
end)
RemoteService.listen("Server","Fetch","DecrementStamina",function(plr,amount)
saveGameContainers[plr]("Do","DecrementStamina",amount)
if saveGameContainers[plr].Stats.Stamina <= 0 then
saveGameContainers[plr].StatsInUse.Stamina = false
end
return saveGameContainers[plr].Stats.Stamina;
end)
RemoteService.listen("Server","Send","RegenStamina",function(plr)
saveGameContainers[plr]("Do","RegenStamina")
end)
RemoteService.listen("Server","Send","SetStatOccupied",function(plr,statName, bool)
if saveGameContainers[plr].Stats[statName] and saveGameContainers[plr].StatsInUse[statName] ~= nil then
if saveGameContainers[plr].Stats[statName] > 0 then
saveGameContainers[plr].StatsInUse[statName] = bool
end
end
end)
RemoteService.listen("Server","Fetch","IsStatOccupied",function(plr,statName)
if saveGameContainers[plr].Stats[statName] and saveGameContainers[plr].StatsInUse[statName] ~= nil then
return saveGameContainers[plr].StatsInUse[statName]
end
end)
BindableService.listen("Send","SetLoadoutItem",function(player,index,weapon)
PlayerLoadouts[player].CurrentItems[index] = weapon
end)
RemoteService.listen("Server","Fetch","GetTeamScore",function(player,team)
if not currentRound then return nil end
if currentRound.Scores[team] then
return currentRound.Scores[team]
end
return nil
end)
RemoteService.listen("Server","Fetch","GetTeamData",function(player,team)
if currentRound then
return currentRound:GetScoreboardConfig(team)
end
return nil
end)
RemoteService.listen("Server","Send","PickupGun",function(player,gunModel)
if player:DistanceFromCharacter(gunModel:GetPrimaryPartCFrame().p) > 10 then return end
local item = ItemStorage:GetNewItem(gunModel.Name):Clone()
local item2 = player.Character:FindFirstChildOfClass("Tool")
local itemName
if item2 then
itemName = item2.Name
end
if item then
item.Parent = player.Pickups
player.Character.Humanoid:UnequipTools()
if gunModel:FindFirstChild("CamoTitle") then
local camo = InventoryService:GetCamoWithTitle(gunModel.CamoTitle.Value)
if camo then
camo:Apply(item)
if gunModel:FindFirstChild("Attachments") then
for _, att in pairs(gunModel.Attachments:GetChildren()) do
local attName = att.Value
if attName then
local Attachment = AttachmentsList[attName]
if Attachment then
Attachment:Apply(item,((item:FindFirstChild("Lid") and Attachment.Slot == "Optics") and "Lid" or "HoldPart"),gunModel.OrigOwner.Value)
end
end
end
end
end
end
if InventoryService.WeaponSet.IsRifle(item.GunType.Value) then
local oldWeapon = player.Character:FindFirstChild(PlayerLoadouts[player].Primary.Name .. "_Holster")
if oldWeapon then
if oldWeapon:FindFirstChild("Gun") then
if oldWeapon.Gun.Value then
oldWeapon.Gun.Value:Destroy()
end
end
oldWeapon:Destroy()
end
wait(2)
PlayerLoadouts[player].Primary = item
elseif InventoryService.WeaponSet.IsPistol(item.GunType.Value) then
local oldWeapon = player.Character:FindFirstChild(PlayerLoadouts[player].Secondary.Name .. "_Holster")
if oldWeapon then
if oldWeapon:FindFirstChild("Gun") then
if oldWeapon.Gun.Value then
oldWeapon.Gun.Value:Destroy()
end
end
oldWeapon:Destroy()
end
wait(2)
PlayerLoadouts[player].Secondary = item
end
if player.Character then
if item:FindFirstChild("UnSheathe") then
item.UnSheathe.Value = true
end
PlayerLoadouts[player]("equip",player)
if itemName then
BindableService.send("DropWeapon",player.Character,itemName,{})
end
gunModel:Destroy()
end
end
end)
BindableService.listen("Send","DropWeapon",function(character,itemName,accessories)
local realItem = ItemStorage:GetNewItem(itemName)
if realItem then
realItem = realItem:Clone()
local itemType =realItem.Type.Value
if itemType then
local item2 = realItem:Clone()
local ItemName = Instance.new("StringValue")
ItemName.Name = "ItemName"
ItemName.Value = itemName
ItemName.Parent = item2
if item2 then
item2 = item2:Clone()
local pPart = item2.PrimaryPart
if pPart then
for _, part in pairs(item2:GetChildren()) do
if part then
if part:IsA("BasePart") and part ~= pPart then
local weld = Instance.new("Weld")
weld.Name = "LootModelWeld"
weld.Part0 = pPart
weld.Part1 = part
weld.C0 = pPart.CFrame:toObjectSpace(part.CFrame)
weld.C1 = CFrame.new()
weld.Parent = pPart
part.Anchored = false
part.CanCollide = true
end
end
end
pPart.Anchored = false
pPart.CanCollide = true
if accessories then
local camo = accessories.camoName
print(camo)
if camo then
local camo2 = InventoryService:GetCamoWithTitle(camo)
if camo2 then
camo2:Apply(item2)
local camVal = Instance.new("StringValue")
camVal.Name = "CamoTitle"
camVal.Value = camo2.Title
camVal.Parent = item2
local plr = game.Players:GetPlayerFromCharacter(character)
if plr then
local PlayerValue = Instance.new("ObjectValue")
PlayerValue.Name = "OrigOwner"
PlayerValue.Value = plr
PlayerValue.Parent = item2
local attachmentLib = AttachmentLibraries[plr]
if attachmentLib then
local attachments = attachmentLib[itemName]
if attachments then
local AttachmentsFolder = Instance.new("Folder")
AttachmentsFolder.Name = "Attachments"
AttachmentsFolder.Parent = item2
for name, att in pairs(attachments) do
if att then
local att1 = AttachmentsList[att]
if att1 then
att1:Apply(item2,((item2:FindFirstChild("Lid") and att.Slot == "Optics") and "Lid" or "Handle"),plr)
end
local attVal = Instance.new("StringValue")
attVal.Name = name
attVal.Value = att
attVal.Parent = AttachmentsFolder
end
end
end
end
end
end
end
end
local hit,pos,dir=raycast(workspace,Ray.new(character.Torso.CFrame.p,Vector3.new(0,-999,0)),{})
if hit and pos and dir then
item2.Parent=workspace.LootIgnore
item2:SetPrimaryPartCFrame(CFrame.new(pos,pos+dir + Vector3.new(0,item2:GetExtentsSize().Y,0))*CFrame.Angles(math.rad(-90),math.rad(RNG:NextInteger(0,360)),0))
DS:AddItem(item2,49)
else
item2:Destroy()
end
end
end
end
end
end)
RemoteService.listen("Server","Send","EquipItem",function(plr,item)
if item:FindFirstChild("Type") then
if not plr.Character:FindFirstChild("Type") then
item.Parent = plr.Character
PlayerLoadouts[plr].CurrentWeapon = item
end
end
end)
RemoteService.listen("Server","Send","UnequipItems",function(plr)
if plr.Character then
for _, item in pairs(plr.Character:GetChildren()) do
if item:FindFirstChild("Type") then
if item.Type:IsA("StringValue") then
item.Parent = plr.Carry
end
end
end
end
end)
RemoteService.listen("Server","Fetch","GetPlayerAchievements",function(player)
local result = {}
for _, ach in pairs(AchievementCache[player]) do
result[#result+1] = ach:ToReplicatedAchievement()
end
return result
end)
RemoteService.listen("Server","Fetch","GetSensitivity",function(plr,weaponType)
return saveGameContainers[plr].weaponSensitivity(weaponType);
end)
RemoteService.listen("Server","Send","SetSensitivity",function(plr,weaponType, val)
if saveGameContainers[plr].weaponSensitivity(weaponType) then
saveGameContainers[plr].weaponSensitivity = {weaponType = weaponType;Value = val}
end
end)
RemoteService.listen("Server","Fetch","IsGameReady",function(player)
return CurrentMap and currentRound
end)
RemoteService.listen("Server","Send","DetonateNade",function(plr,bt,...)
print("Detonating " .. bt)
Detonator:RunBehavior(bt,...)
end)
BindableService.listen("Fetch","GetPvPRank",function(plr)
return saveGameContainers[plr].pvpRank();
end)
BindableService.listen("Send","BreakWindow",function(hit)
if not hit then return end
local shat=Instance.new("Sound")
shat.SoundId="http://roblox.com/asset/?id=144884907"
shat.TimePosition = .1
shat.Parent = hit
shat:Play()
local sx,sy,sz=hit.Size.x,hit.Size.y,hit.Size.z
for x=1,4 do
for y=1,4 do
local part=hit:Clone()
local position=Vector3.new(x-2.1,y-2.1,0)*Vector3.new(sx/4,sy/4,sz)
part.Size=Vector3.new(sx/4,sy/4,sz)
part.CFrame=hit.CFrame*(CFrame.new(part.Size/8)-hit.Size/8+position)
part.Velocity=Vector3.new(math.random(-10,10) ,math.random(-10,10),math.random(-10,10)) * hit.Size.magnitude
part.Velocity = part.Velocity - Vector3.new(x * math.sign(part.Velocity.X),y * math.sign(part.Velocity.Y),part.Velocity.Z)
-- for _, side in pairs({"Top","Bottom","Front","Back","Left","Right"}) do
-- part[side .. "Surface"] = Enum.SurfaceType.SmoothNoOutlines
-- end
part.Parent=workspace.ShatterIgnore
part.Name="Shatter"
spawn(function()
wait(2.5)
local tI = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local goals = {
Transparency = 1;
}
local tween = TweenService:Create(part,tI,goals)
tween:Play()
tween.Completed:wait()
part:Destroy()
end)
part.Anchored=false
end
end
hit:Destroy()
end)
RemoteService.listen("Server","Fetch","setupViewModel",function(player,Gun,Vars)
local S = require(Gun.SETTINGS)
local gunIgnore = OBJ("Model")
gunIgnore.Name = "gunIgnore_"..player.Name
gunIgnore.Parent = workspace.ignoreModel
local torso = Vars.Torso
local playerFolder = OBJ("Model")
playerFolder.Name = "playerFolder"
playerFolder.Parent = gunIgnore
Vars.Humanoid.AutoRotate = false
Vars.Shoulders.Right.Part1 = nil
Vars.Shoulders.Left.Part1 = nil
local headBase = Instance.new("Part")
headBase.Transparency = 1
headBase.Name = "headBase"
headBase.CanCollide = false
headBase.FormFactor = Enum.FormFactor.Custom
headBase.Size = V3(0.2, 0.2, 0.2)
headBase.BottomSurface = Enum.SurfaceType.Smooth
headBase.TopSurface = Enum.SurfaceType.Smooth
headBase.Parent = playerFolder
local headWeld = OBJ("Motor6D")
headWeld.Part0 = torso
headWeld.Part1 = headBase
headWeld.C0 = CF(0, 1.5, 0)
headWeld.Parent = torso
local headWeld2 = OBJ("Weld")
headWeld2.Part0 = headBase
headWeld2.Part1 = Vars.Head
headWeld2.Parent = headBase
local animBase = OBJ("Part")
animBase.Transparency = 1
animBase.Name = "animBase"
animBase.CanCollide = false
animBase.FormFactor = Enum.FormFactor.Custom
animBase.Size = V3(0.2, 0.2, 0.2)
animBase.BottomSurface = Enum.SurfaceType.Smooth
animBase.TopSurface = Enum.SurfaceType.Smooth
animBase.Parent = playerFolder
local animWeld = Instance.new("Motor6D")
animWeld.Name = "animWeld"
animWeld.Part0 = animBase
animWeld.Part1 = headBase
animWeld.Parent = animBase
local armBase = OBJ("Part")
armBase.Transparency = 1
armBase.Name = "ArmBase"
armBase.CanCollide = false
armBase.FormFactor = Enum.FormFactor.Custom
armBase.Size = V3(0.2, 0.2, 0.2)
armBase.BottomSurface = Enum.SurfaceType.Smooth
armBase.TopSurface = Enum.SurfaceType.Smooth
armBase.Parent = playerFolder
local ABWeld =Instance.new("Motor6D")
ABWeld.Part0 = armBase
ABWeld.Part1 = animBase
ABWeld.Name = "ABWeld"
ABWeld.Parent = armBase
local LArmBase = OBJ("Part")
LArmBase.Transparency = 1
LArmBase.Name = "LArmBase"
LArmBase.CanCollide = false
LArmBase.FormFactor = Enum.FormFactor.Custom
LArmBase.Size = V3(0.2, 0.2, 0.2)
LArmBase.BottomSurface = Enum.SurfaceType.Smooth
LArmBase.TopSurface = Enum.SurfaceType.Smooth
LArmBase.Parent = playerFolder
local RArmBase = OBJ("Part")
RArmBase.Transparency = 1
RArmBase.Name = "RArmBase"
RArmBase.CanCollide = false
RArmBase.FormFactor = Enum.FormFactor.Custom
RArmBase.Size = V3(0.2, 0.2, 0.2)
RArmBase.BottomSurface = Enum.SurfaceType.Smooth
RArmBase.TopSurface = Enum.SurfaceType.Smooth
RArmBase.Parent = playerFolder
local LWeld = Instance.new("Motor6D")
LWeld.Name = "LWeld"
LWeld.Part0 = armBase
LWeld.Part1 = LArmBase
LWeld.C0 = Vars.armC0[1]
LWeld.C1 = S.equipSettings.leftArmC1
LWeld.Parent = armBase
local RWeld = Instance.new("Motor6D")
RWeld.Name = "RWeld"
RWeld.Part0 = armBase
RWeld.Part1 = RArmBase
RWeld.C0 = Vars.armC0[2]
RWeld.C1 = S.equipSettings.rightArmC1
RWeld.Parent = armBase
local LWeld2 = Instance.new("Motor6D")
LWeld2.Name = "LWeld"
LWeld2.Part0 = LArmBase
LWeld2.Part1 = Vars.LArm
LWeld2.Parent = LArmBase
local RWeld2 = Instance.new("Motor6D")
RWeld2.Name = "RWeld"
RWeld2.Part0 = RArmBase
RWeld2.Part1 = Vars.RArm
RWeld2.Parent = RArmBase
local LLegWeld = Instance.new("Motor6D")
LLegWeld.Name = "LLegWeld"
LLegWeld.Part0 = torso
LLegWeld.C0 = CF(-0.5, -2, 0)
LLegWeld.Parent = torso
local RLegWeld = Instance.new("Motor6D")
RLegWeld.Name = "RLegWeld"
RLegWeld.Part0 = torso
RLegWeld.C0 = CF(0.5, -2, 0)
RLegWeld.Parent = torso
if Vars.RArm:FindFirstChild("RightGrip") then
Vars.RArm.RightGrip:Destroy()
end
local Grip = Instance.new("Motor6D")
Grip.Name = "RightGrip"
Grip.Part0 = Vars.RArm
Grip.Part1 = Gun.Handle
Grip.C0 = CF(0, -1, 0) * CFANG(-0.5 * math.pi, 0, 0)
Grip.C1 = S.equipSettings.GripC1
Grip.Parent = Vars.RArm
local Grip2 = Instance.new("Motor6D")
Grip2.Name = "LeftGrip"
Grip2.Parent = Vars.LArm
return gunIgnore, playerFolder, headWeld, headWeld2, armBase, animWeld, ABWeld, LWeld, RWeld, LWeld2, RWeld2, LLegWeld, RLegWeld, Grip, Grip2
end)
RemoteService.listen("Server","Send","BreakWindow",function(player,hit)
if not hit then return end
local shat=Instance.new("Sound")
shat.SoundId="http://roblox.com/asset/?id=144884907"
shat.TimePosition = .1
shat.Parent = hit
shat:Play()
local sx,sy,sz=hit.Size.x,hit.Size.y,hit.Size.z
for x=1,4 do
for y=1,4 do
local part=hit:Clone()
local position=Vector3.new(x-2.1,y-2.1,0)*Vector3.new(sx/4,sy/4,sz)
part.Size=Vector3.new(sx/4,sy/4,sz)
part.CFrame=hit.CFrame*(CFrame.new(part.Size/8)-hit.Size/8+position)
part.Velocity=Vector3.new(math.random(-10,10) ,math.random(-10,10),math.random(-10,10)) * hit.Size.magnitude
part.Velocity = part.Velocity - Vector3.new(x * math.sign(part.Velocity.X),y * math.sign(part.Velocity.Y),part.Velocity.Z)
-- for _, side in pairs({"Top","Bottom","Front","Back","Left","Right"}) do
-- part[side .. "Surface"] = Enum.SurfaceType.SmoothNoOutlines
-- end
part.Parent=workspace.ShatterIgnore
part.Name="Shatter"
spawn(function()
wait(2.5)
local tI = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local goals = {
Transparency = 1;
}
local tween = TweenService:Create(part,tI,goals)
tween:Play()
tween.Completed:wait()
part:Destroy()
end)
part.Anchored=false
end
end
if hit.Name == "GlassCheckpoint1" then
RemoteService.send("Client",player,"MarkCallSign","wallBroken")
end
hit:Destroy()
end)
PhysicsService:CreateCollisionGroup("CoverPoint")
ChatSI:Init()
ChatSI:Start()
BindableService.start()
RemoteService.startServer()
AntiSpeed.Init()
AntiSpeed.Event:Connect(function(player)
print("Votekick here")
end)
Lighting:SetMinutesAfterMidnight(0)
while wait() do
local round = Round.new(60,nil,1,4)
if round then
round:Init()
currentRound = round
currentRound:CheckForPlayers()
repeat
wait()
until
#currentRound.Requirements <= 0
currentRound:RunIntermission(15)
currentRound:ChooseMap()
CurrentMap = round.CurrentMap
wait(3)
if CurrentMap then
currentRound.KillAdded = KillService.KillAdded:connect(function(plr,kill)
local team = plr.Team
if team and currentRound.GameReady then
round:AddScore(plr,team,1)
round:AddPlayerScore(plr,1)
end
end)
currentRound:RunMatch(10,10 * 60)
currentRound.KillAdded:disconnect()
currentRound:Cleanup()
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment