Created
May 9, 2018 17:29
-
-
Save Aerodos12/826623181f12f82c1a4f0907af9f7580 to your computer and use it in GitHub Desktop.
CrossWar GS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------------------------------- | |
--------------------[ CHARACTER LOADING ]--------------------------------------------- | |
-------------------------------------------------------------------------------------- | |
local FFC = game.FindFirstChild | |
local WFC = game.WaitForChild | |
local Services = {} | |
Services.DS = game:GetService("Debris") | |
Services.CP = game:GetService("ContentProvider") | |
Services.RS = game:GetService("RunService") | |
Services.UIS = game:GetService("UserInputService") | |
Services.CAS = game.ContextActionService | |
Services.WS = workspace | |
Services.RepStorage = game.ReplicatedStorage | |
Services.KIAPI = require(Services.RepStorage.KeyInputAPI) | |
Services.Plrs = game.Players | |
repeat wait() until Services.Plrs.LocalPlayer.Character | |
repeat wait() until Services.Plrs.LocalPlayer.Character:IsDescendantOf(Services.WS) | |
wait(1 * 0.05) | |
local RemoteService = require(game.ReplicatedStorage.RemoteService) | |
local CameraService = require(game.ReplicatedStorage.CameraService) | |
local bindableService = require(game.ReplicatedStorage.BindingService)(Services.Plrs.LocalPlayer) | |
-------------------------------------------------------------------------------------- | |
--------------------[ IGNORE MODEL ]-------------------------------------------------- | |
-------------------------------------------------------------------------------------- | |
local WalkingGamepad =false | |
local TICK,UDIM2 = tick,UDim2.new | |
local ignoreModel = Services.WS.ignoreModel | |
local RPGM = require(Services.RepStorage.RPGMathProvider) | |
local grenadeFolder = ignoreModel.grenadeFolder | |
--local KI = require(game.ReplicatedStorage.KeyInputAPI) | |
local GunMath = {} | |
-------------------------------------------------------------------------------------- | |
--------------------[ CONSTANTS ]----------------------------------------------------- | |
-------------------------------------------------------------------------------------- | |
local shortWait = Services.RS.RenderStepped.wait | |
local Gun = script.Parent | |
local Handle = WFC(Gun,"Handle") | |
local AimPart = WFC(Gun,"AimPart") | |
local Main = {} | |
local Ammo = WFC(Gun,"Ammo") | |
local ClipSize = WFC(Gun,"ClipSize") | |
local StoredAmmo = WFC(Gun,"StoredAmmo") | |
local Libraries = {} | |
Libraries.Network = require(WFC(Services.RepStorage.RemoteService,"Plugin_Gun",200))(game.Players.LocalPlayer,script.Parent.Name,true,Gun) | |
Libraries.GLFolder = Services.RepStorage:WaitForChild("GunLibraries",200); | |
Libraries.Particle = require(WFC(Libraries.GLFolder,"Particle",200)); | |
Libraries.Spring = require(WFC(Libraries.GLFolder,"Spring",200)); | |
Libraries.TweenIndicator = require(WFC(Libraries.GLFolder,"TweenIndicator",200)); | |
Libraries.Anims = require(WFC(Gun,"ANIMATIONS",200)); | |
Libraries.Plugins = require(WFC(Gun,"PLUGINS",200)); | |
Libraries.Firemodes = require(WFC(Gun,"FIREMODES",200)); | |
Libraries.Keybinds = require(WFC(Gun,"KEYBINDS",200)); | |
Libraries.DownActions = require(WFC(Gun,"ACTIONS_DOWN",200)); | |
Libraries.UpActions = require(WFC(Gun,"ACTIONS_UP",200)); | |
Libraries.Haptics = require(WFC(Gun,"HAPTICS",200)); | |
Libraries.Cartridges = require(game.ReplicatedStorage.Settings.Cartridges) | |
Libraries.XAdapt = require(game.ReplicatedStorage.XAdapt) | |
S = require(WFC(Gun,"SETTINGS",200)); | |
Libraries.PrimitiveAnim = require(WFC(Libraries.GLFolder,"PrimitiveAnim",600)) | |
local Player = game.Players.LocalPlayer | |
local Char = Player.Character | |
Humanoid = Char:WaitForChild("Humanoid",200) | |
Torso = Char:WaitForChild("Torso",200) | |
Head = Char:WaitForChild("Head",200); | |
HRP = Char:WaitForChild("HumanoidRootPart",200) | |
Root = HRP:WaitForChild("RootJoint",200) | |
Neck = Torso:WaitForChild("Neck",200) | |
LArm = Char:WaitForChild("Left Arm",200) | |
RArm = Char:WaitForChild("Right Arm",200) | |
LLeg = Char:WaitForChild("Left Leg",200) | |
RLeg = Char:WaitForChild("Right Leg",200) | |
local fakeLArm,fakeRArm | |
local HUD = Player.PlayerGui:WaitForChild("HUD",200) | |
local mainGUI = HUD:FindFirstChild(Services.UIS.TouchEnabled and "Main_Mobile" or "Main"):WaitForChild("gunUI",200) | |
local runAsync = function(threadFunc) | |
coroutine.resume(coroutine.create(threadFunc)) | |
end | |
local PenetrationTries = S.penetrationSettings.maxTries | |
local ArmWelds = { | |
LWeld = nil; | |
RWeld = nil; | |
} | |
local SheatheWeld | |
local KeyInputConnections = {} | |
local Activators = {} | |
local Interface = { | |
Cam = game.Workspace.CurrentCamera; | |
crossHair = (not S.gunType.Shot and mainGUI:WaitForChild("crossHair") or mainGUI:WaitForChild("ShotgunCrosshair")); | |
HUD = ( not Services.UIS.TouchEnabled and mainGUI:WaitForChild("HUD") or mainGUI:WaitForChild("MobileHUD")); | |
Scope = mainGUI:WaitForChild("Scope"); | |
fireSelect = mainGUI:WaitForChild("fireSelect"); | |
hitMarker = mainGUI:WaitForChild("hitMarker"); | |
Sens = mainGUI:WaitForChild("Sens"); | |
M2 = Player:GetMouse(); | |
LethalIcons = { | |
"http://www.roblox.com/asset/?id=194849880"; | |
"http://www.roblox.com/asset/?id=195727791"; | |
"http://www.roblox.com/asset/?id=195728137"; | |
"http://www.roblox.com/asset/?id=218151830"; | |
}; | |
TacticalIcons = { | |
"http://www.roblox.com/asset/?id=195728473"; | |
"http://www.roblox.com/asset/?id=195728693"; | |
}; | |
} | |
if Interface.crossHair == mainGUI:WaitForChild("crossHair") then | |
mainGUI:WaitForChild("ShotgunCrosshair").Visible = false | |
else | |
mainGUI:WaitForChild("crossHair").Visible = false | |
end | |
local scopeMain = Interface.Scope:WaitForChild("Main") | |
local scopeSteady = Interface.Scope:WaitForChild("Steady") | |
local fireModes = Interface.fireSelect:WaitForChild("Modes") | |
local modeGUI = (not Services.UIS.TouchEnabled and FFC(Interface.HUD,"Mode"):FindFirstChild("Main") or Interface.HUD:WaitForChild("Mode")) | |
local clipAmmoGUI =(not Services.UIS.TouchEnabled and FFC(Interface.HUD,"Ammo"):FindFirstChild("Clip") or Interface.HUD:WaitForChild("Ammo")) | |
local AmmoBar =(not Services.UIS.TouchEnabled and Interface.HUD:WaitForChild("Ammo"):WaitForChild("AmmoBar2",20) or nil) | |
local crossParts | |
if not S.gunType.Shot then | |
crossParts = { | |
Interface.crossHair:WaitForChild("A"):WaitForChild("Line"); | |
Interface.crossHair:WaitForChild("B"):WaitForChild("Line"); | |
Interface.crossHair:WaitForChild("C"):WaitForChild("Line"); | |
Interface.crossHair:WaitForChild("D"):WaitForChild("Line"); | |
}; | |
end | |
Interface.ModingSystem = Libraries.XAdapt:CreateInputScheme({ | |
{ | |
"Basic"; | |
{ | |
"ADS"; | |
"Sprint"; | |
"scopeSteady"; | |
"raiseStance"; | |
"lowerStance"; | |
"selectFire"; | |
"Reload"; | |
}; | |
}; | |
{ | |
"Tactical"; | |
{ | |
"Spot"; | |
"ThrowTactical"; | |
"ThrowLethal"; | |
"BoltAction"; | |
"ToggleBipod"; | |
}; | |
}; | |
{ | |
"Cosmetic"; | |
{ | |
"Inspect"; | |
}; | |
}; | |
}) | |
local NVEffect, NVB | |
local VantagePoint = WFC(scopeMain,"VantagePoint",200) | |
local MIN,MAX = math.min,math.max | |
local ABS, HUGE, FLOOR, CEIL = math.abs, math.huge, math.floor, math.ceil | |
local SIN, COS, TAN = math.sin, math.cos, math.tan | |
local RAD = function(angle) | |
return angle * (math.pi/180) | |
end | |
local V3 = { | |
RAW = Vector3.new; | |
ID = Vector3.new(); | |
} | |
V3.lerp = V3.ID.lerp | |
local VEC2 = Vector2.new | |
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 RSEED = math.randomseed | |
ATAN,RANDOM = math.atan,math.random | |
local ATAN2 = function(x, y) | |
local r = ATAN(y / x) | |
if x < 0 then | |
r = r + math.pi | |
end | |
return r | |
end | |
local MeshTypes = Enum.MeshType | |
local OBJ = { | |
RAW = Instance.new; | |
Clone = game.Clone; | |
GetKids = game.GetChildren; | |
Destroy = game.Destroy | |
} | |
local SoundLib = { | |
Play = OBJ.RAW("Sound").Play; | |
} | |
local BC,Fonts,FontSizes = BrickColor.new,Enum.Font,Enum.FontSize | |
local C3,CameraTypes = Color3.new,Enum.CameraType | |
local Materials,InputTypes = Enum.Material,Enum.UserInputType | |
local INSERT = function(tableObj,item) | |
tableObj[#tableObj+1] = item | |
end | |
local REMOVE = function(tableObj,i) | |
tableObj[i] = nil | |
end | |
local PAIRS = pairs | |
local maxStamina = RemoteService.fetch("Server","GetStamina","Max") | |
local maxSteadyTime = S.scopeSettings.steadyTime * 60 | |
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 Ignore = { | |
Char; | |
ignoreModel; | |
} | |
local Shoulders = { | |
Right = Torso:WaitForChild("Right Shoulder"); | |
Left = Torso:WaitForChild("Left Shoulder"); | |
} | |
local Sine = function(X) | |
return SIN(RAD(X)) | |
end | |
local Linear = function(X) | |
return (X * 0.0111111111111) | |
end | |
local Quad = function(X) | |
return (X * 0.0111111111111)^2 | |
end | |
local QuadOut = function(X) | |
local T = (X/90) | |
return T * (2 - T) | |
end | |
local RAY = { | |
RAW = Ray.new; | |
CAST = workspace.FindPartOnRayWithIgnoreList; | |
} | |
-------------------------------------------------------------------------------------- | |
--------------------[ VARIABLES ]----------------------------------------------------- | |
-------------------------------------------------------------------------------------- | |
local Forward = false | |
local Backward = false | |
local Idling = false | |
local Walking = false | |
local Running = false | |
local Climbing = false | |
local crawlCamRot = 0 | |
local crawlAlpha = 0 | |
local idleAlpha = 1 | |
local walkAlpha = 0 | |
local isCrawling = false | |
local isIdling = false | |
local isWalking = false | |
local isRunning = false | |
local Aimed = false | |
local Aiming = false | |
local aimAlpha = 0 | |
local headOffset = VEC2(COS(RAD(90) - S.aimSettings.headTilt) * 0.5, 1 + SIN(RAD(90) - S.aimSettings.headTilt) * 0.5) | |
local Reloading = false | |
local breakReload = false | |
local magVisible = true | |
local newMag = false | |
local Knifing = false | |
local MB1Down = false | |
local Firing = false | |
local canFire = true | |
local firstShot = false | |
local shotCount = 0 | |
local lastSideRecoil = {0, 0} | |
local recoilAnim = { | |
Pos = V3.RAW(); | |
Rot = V3.RAW(); | |
Code = nil; | |
} | |
local numModes = 0 | |
local rawFireMode = 1 | |
local canSelectFire = true | |
local Modes = {} | |
local onGround = true | |
local startFallHeight = 0 | |
local jumpAnim = { | |
Pos = 0; | |
Rot = 0; | |
Code = 0; | |
} | |
local BoltWelds = {} | |
local boltAnim = {} | |
local runReady = true | |
local runKeyPressed = false | |
local chargingStamina = false | |
local AimingIn = false | |
local AimingOut = false | |
local Stamina = RemoteService.fetch("Server","GetStamina","Reg") | |
local currentSteadyTime = S.scopeSettings.steadyTime * 60 | |
local camSteady = false | |
local takingBreath = false | |
local steadyKeyPressed = false | |
local Grips = { | |
Left = nil; | |
Right = nil; | |
Current = "Right"; | |
} | |
local ArmBase | |
local spreadZoom = "unAimed" | |
local spreadStance = "Stand" | |
local spreadMotion = "Idling" | |
local baseSpread = S.spreadSettings.unAimed.Stand.Idling | |
local currentSpread = 0 | |
local loweringSpread = false | |
local Sensitivity = { | |
mouse = RemoteService.fetch("Server","GetSensitivity","Gun"); | |
aim = RemoteService.fetch("Server","GetSensitivity","Gun"); | |
touch = Vector2.new(math.pi*2.25, math.pi*2) | |
} | |
local ammoInClip = 0 | |
local Stance = 0 | |
local stanceSway = 1 | |
local camSway = 1 | |
local camAng = VEC2() | |
local armTilt = 0 | |
local moveAng = 0 | |
local animCode = 0 | |
local desiredXOffset = 0 | |
local desiredYOffset = 0 | |
local currentXOffset = 0 | |
local currentYOffset = 0 | |
local recoilAnimMultiplier = 1 | |
local jumpAnimMultiplier = 1 | |
local translationDivisor = 7 | |
local rotationMultiplier = S.momentumSettings.Amplitude.unAimed | |
local armTiltMultiplier = 1 | |
local equipAnimPlaying = false | |
local armModel | |
local crossOffset = 0 | |
local camOffsets = { | |
guiScope = Libraries.PrimitiveAnim.new(V3.RAW()); | |
Reload = Libraries.PrimitiveAnim.new(V3.RAW(),nil); | |
Recoil = Libraries.PrimitiveAnim.new(V3.RAW(),nil); | |
} | |
local Anim = Libraries.PrimitiveAnim.new(V3.RAW(),0,V3.RAW(),0); | |
local gunParts = {} | |
local revolverMagParts = {} | |
local Connections = {} | |
local Combos = {} | |
local WalkingTouch = false | |
local function markHit() | |
runAsync(function() | |
if mainGUI:IsDescendantOf(game) then | |
Interface.hitMarker.Visible = true | |
local startMark = TICK() | |
Interface.hitMarker.lastMark.Value = startMark | |
wait(0.5) | |
if Interface.hitMarker.lastMark.Value <= startMark then | |
Interface.hitMarker.Visible = false | |
end | |
end | |
end) | |
end | |
function getMagCount(CSize,mode) | |
local SAmmo = StoredAmmo.Value | |
local AmmoVal = Ammo.Value | |
local remainder = SAmmo - (CSize - AmmoVal) % CSize | |
local magCount | |
if mode:lower() == "true" then | |
magCount = FLOOR((SAmmo - (CSize - AmmoVal)) / CSize) | |
elseif mode:lower() == "estimated" then | |
magCount = FLOOR(SAmmo / CSize) | |
end | |
return magCount | |
end | |
local function loadAsset(assetType,assetEntity) | |
Services.CP:Preload(S[assetEntity.."Settings"][assetType]) | |
end | |
-------------------------------------------------------------------------------------- | |
--------------------[ PRE-LOADING ]--------------------------------------------------- | |
-------------------------------------------------------------------------------------- | |
loadAsset("soundId","explosion") | |
loadAsset("Texture","hole") | |
loadAsset("Texture","blood") | |
Services.CP:Preload("http://www.roblox.com/asset/?id=126877530") --The dark green arrow in the select fire gui | |
Services.CP:Preload("http://www.roblox.com/asset/?id=55754953") --The circle in the select fire gui | |
-------------------------------------------------------------------------------------- | |
--------------------[ GUN SETUP ]----------------------------------------------------- | |
-------------------------------------------------------------------------------------- | |
Libraries.Network.send("Server","SetCam_"..Player.UserId,Interface.Cam) | |
local gunMomentum = Libraries.Spring.new(V3.RAW()) | |
gunMomentum.s = S.momentumSettings.Speed | |
gunMomentum.d = S.momentumSettings.Damper | |
local gunRecoilSpring = Libraries.Spring.new(V3.RAW()) | |
gunRecoilSpring.s = S.recoilSettings.springSpeed | |
gunRecoilSpring.d = S.recoilSettings.springDamper | |
local camRecoilSpring = Libraries.Spring.new(V3.RAW()) | |
camRecoilSpring.s = 35 | |
camRecoilSpring.d = 0.5 | |
local crossSpring = Libraries.Spring.new(V3.RAW(crossOffset + (baseSpread + currentSpread) * 50, 0, 0)) | |
crossSpring.s = 20 | |
crossSpring.d = 0.75 | |
local walkSpeedSpring = Libraries.Spring.new(V3.RAW(S.walkSpeeds.Base,0,0)) | |
walkSpeedSpring.s = 8 | |
local crossScale = Libraries.Spring.new(V3.RAW(1,0,0)) | |
crossScale.s = 12 | |
crossScale.d = 0.8 | |
local CurrentCartridge = Libraries.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 | |
runAsync(function() | |
for _, part in pairs(Gun:GetChildren()) do | |
if part:IsA("BasePart") then | |
if part.Name:sub(1,3) == "Mag" and not part.Name:find("Case") then | |
INSERT(revolverMagParts,part) | |
end | |
end | |
end | |
table.sort(revolverMagParts,function(a,b) | |
return tonumber(a.Name:sub(4,4)) < tonumber(b.Name:sub(4,4)) | |
end) | |
end) | |
function aimedGripCF(aimPart) | |
local handleCF = Torso.CFrame * CF.RAW(0, 0.5, 0) * armC0[2] * S.aimedC1.rightArm:inverse() * Grips.Right.C0 | |
local handleOffset = CF.TOS(aimPart.CFrame,Handle.CFrame) | |
return CF.TOS(((Torso.CFrame * CF.RAW(headOffset.X, headOffset.Y, 0)) * handleOffset),handleCF) | |
end | |
function getIndex(item,list) | |
local i = nil | |
for i2, v in pairs(list) do | |
if v == item then | |
i = i2 | |
end | |
end | |
return i | |
end | |
-------------------------------------------------------------------------------------- | |
--------------------[ MAIN PROGRAM ]-------------------------------------------------- | |
-------------------------------------------------------------------------------------- | |
--------------------[ ARM CREATION FUNCTION ]----------------------------------------- | |
local creationFunctions = { | |
["Modes"] = function(args) | |
numModes = 0 | |
for i, v in PAIRS(S.selectFireSettings.Modes) do | |
if v then | |
numModes = numModes + 1 | |
end | |
end | |
if #Main >= 2 and Gun:FindFirstChild("GrenadeCaliber") then | |
numModes= numModes + 1 | |
end | |
Modes = {}; | |
local currentMode = 0 | |
for i, v in PAIRS(S.selectFireSettings.Modes) do | |
local Frame = OBJ.RAW("Frame") | |
Frame.BackgroundTransparency = 1 | |
Frame.Name = currentMode | |
Frame.Position = UDIM2(currentMode,0,0) | |
Frame.Size = UDIM2(1,0,1,0) | |
Frame.Parent = fireModes | |
Frame.ZIndex = 2 | |
local modeLabel = OBJ.RAW("TextLabel") | |
modeLabel.BackgroundTransparency = 1 | |
modeLabel.Name = "Label" | |
modeLabel.Position = UDIM2(0, 0, 0, 0) | |
modeLabel.Size = UDIM2(1,0,1,0) | |
modeLabel.Font = "Highway" | |
modeLabel.TextSize = 18 | |
modeLabel.Text = v:upper() | |
modeLabel.TextColor3 = C3(1, 1, 1) | |
modeLabel.TextScaled = false | |
modeLabel.TextTransparency = 0 | |
modeLabel.TextWrapped = true | |
modeLabel.Parent = Frame | |
INSERT(Modes, v:upper()) | |
currentMode = currentMode + 1 | |
end | |
if #Main >= 2 and Gun:FindFirstChild("GrenadeCaliber") then | |
local Frame = OBJ.RAW("Frame") | |
Frame.BackgroundTransparency = 1 | |
Frame.Name = currentMode | |
Frame.Position = UDIM2(currentMode,0,0) | |
Frame.Size = UDIM2(1,0,1,0) | |
Frame.Parent = fireModes | |
Frame.ZIndex = 2 | |
local modeLabel = OBJ.RAW("TextLabel") | |
modeLabel.BackgroundTransparency = 1 | |
modeLabel.Name = "Label" | |
modeLabel.Position = UDIM2(0, 0, 0, 0) | |
modeLabel.Size = UDIM2(1,0,1,0) | |
modeLabel.Font = "Highway" | |
modeLabel.TextSize = 18 | |
modeLabel.Text = "GRENADE" | |
modeLabel.TextColor3 = C3(1, 1, 1) | |
modeLabel.TextScaled = false | |
modeLabel.TextTransparency = 0 | |
modeLabel.TextWrapped = true | |
modeLabel.Parent = Frame | |
INSERT(Modes,("Grenade"):upper()) | |
currentMode = currentMode + 1 | |
end | |
table.sort(Modes,function(a,b) | |
return getIndex(a,Modes) == getIndex(S.defaultMode:upper(),Modes) | |
end) | |
-- guiAngOffset = -15 * (numModes ^ 3) + 150 * (numModes ^ 2) - 525 * numModes + 660 | |
return true | |
end; | |
["Bullet"] = function(args) | |
return (createBullet(args[2],args[3])) | |
end | |
} | |
function create(...) | |
local args = {...} | |
return creationFunctions[args[1]](args) | |
end | |
local function currentGripArm() | |
return Grips.Current == "Left" and LArm or RArm | |
end | |
function getFirePort(index) | |
return Main[index] | |
end | |
--------------------[ MATH FUNCTIONS ]------------------------------------------------ | |
GunMath.Map = function(Val, fromLow, fromHigh, toLow, toHigh) | |
return (Val - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow | |
end | |
GunMath.numLerp = function(A, B, Alpha) | |
return A + (B - A) * Alpha | |
end | |
GunMath.RAND = function(Min, Max) | |
return GunMath.numLerp(Min, Max, RANDOM()) | |
--[[local Inverse = 1 / (Accuracy or 1) | |
return (math.random(Min * Inverse, Max * Inverse) / Inverse)]] | |
end | |
GunMath.Round = function(Num, toNearest) | |
return FLOOR(Num / toNearest + 0.5) * toNearest | |
end | |
GunMath.getNearestPoint = function(A, B, Origin) | |
local A2 = (A - Origin).magnitude | |
local B2 = (B - Origin).magnitude | |
return (MIN(A2, B2) == A2 and A or B) | |
end | |
--------------------[ TWEEN FUNCTIONS ]----------------------------------------------- | |
function tween(...) | |
local args = {...} | |
if args then | |
if args[1] == "Joint" then | |
local Joint = args[2] | |
local newC0 = args[3] | |
local newC1 = args[4] | |
local Alpha = args[5] | |
local Duration = args[6] | |
runAsync(function() | |
local newCode = RANDOM(-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 | |
shortWait(Services.RS.Heartbeat) | |
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 newC0 then Joint.C0 = startC0:lerp(newC0, Alpha(X)) Libraries.Network.send("Server","SetJointC0_"..Player.UserId,Joint,Joint.C0) end | |
if newC1 then Joint.C1 = startC1:lerp(newC1, Alpha(X)) Libraries.Network.send("Server","SetJointC1_"..Player.UserId,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 | |
end | |
if args[1] == "Cam" then | |
local Key = args[2] | |
local newRot = args[3] | |
local Alpha = args[4] | |
local Duration = args[5] | |
runAsync(function() | |
local newCode = RANDOM(-1e9, 1e9) | |
camOffsets[Key].Code = newCode | |
local Increment = 1.5 / Duration | |
local prevRot = camOffsets[Key].Rot | |
local X = 0 | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local newX = X + Increment | |
X = (newX > 90 and 90 or newX) | |
if camOffsets[Key].Code ~= newCode then break end | |
if (not Selected) then break end | |
camOffsets[Key].Rot = V3.lerp(prevRot,newRot, Alpha(X)) | |
if X == 90 then break end | |
end | |
if camOffsets[Key].Code == newCode then | |
camOffsets[Key].Code = nil | |
end | |
end) | |
end | |
if args[1] == "textTrans" then | |
local textLabel = args[2] | |
local newTrans = args[3] | |
local Alpha = args[4] | |
local Duration = args[5] | |
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 | |
shortWait(Services.RS.Heartbeat) | |
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 = GunMath.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 | |
if args[1] == "Recoil" then | |
local newPos = args[2] | |
local newRot = args[3] | |
local Alpha = args[4] | |
local Duration = args[5] | |
runAsync(function() | |
local newCode = RANDOM(-1e9, 1e9) | |
recoilAnim.Code = newCode | |
local Increment = 1.5 / Duration | |
local prevPos = recoilAnim.Pos | |
local prevRot = recoilAnim.Rot | |
local X = 0 | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local newX = X + Increment | |
X = (newX > 90 and 90 or newX) | |
if recoilAnim.Code ~= newCode then break end | |
if (not Selected) then break end | |
recoilAnim.Pos = V3.lerp(prevPos,newPos, Alpha(X)) | |
recoilAnim.Rot = V3.lerp(prevRot,newRot, Alpha(X)) | |
if X == 90 then break end | |
end | |
if recoilAnim.Code == newCode then | |
recoilAnim.Code = nil | |
end | |
end) | |
elseif args[1] == "Crawl" then | |
local tempCrawlAnim = args[2] | |
local animEnd = args[3] | |
if not animEnd then | |
runAsync(function() | |
local startCamRot = crawlCamRot | |
local startLLegCF = LLegWeld.C1 | |
local startRLegCF = RLegWeld.C1 | |
local t0 = TICK() | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local Alpha = MIN((TICK() - t0) * 3.33333, 1) * 90 | |
if (not isCrawling) then break end | |
if (not Selected) then break end | |
crawlCamRot = GunMath.numLerp(startCamRot, tempCrawlAnim.Camera, Sine(Alpha)) | |
CameraService.CurrentModeVars:SetCrawlCamRot(crawlCamRot) | |
LLegWeld.C1 = startLLegCF:lerp(tempCrawlAnim.leftLeg, Linear(Alpha)) | |
RLegWeld.C1 = startRLegCF:lerp(tempCrawlAnim.rightLeg, Linear(Alpha)) | |
Libraries.Network.send("Server","changeLLegWeldC1_"..Player.UserId,LLegWeld,LLegWeld.C1) | |
Libraries.Network.send("Server","changeRLegWeldC1_"..Player.UserId,RLegWeld,RLegWeld.C1) | |
if Alpha == 90 then break end | |
end | |
end) | |
else | |
runAsync(function() | |
local startCamRot = crawlCamRot | |
local startLLegCF = LLegWeld.C1 | |
local startRLegCF = RLegWeld.C1 | |
local t0 = TICK() | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local Alpha = MIN((TICK() - t0) * 3.333333333, 1) * 90 | |
if isCrawling then break end | |
if (not Selected) then break end | |
crawlCamRot = GunMath.numLerp(startCamRot, 0, Sine(Alpha)) | |
CameraService.CurrentModeVars:SetCrawlCamRot(crawlCamRot) | |
LLegWeld.C1 = startLLegCF:lerp(CF.RAW(), Linear(Alpha)) | |
RLegWeld.C1 = startRLegCF:lerp(CF.RAW(), Linear(Alpha)) | |
if Alpha == 90 then break end | |
end | |
end) | |
end | |
elseif args[1] == "Aim" then | |
local currentFOV = Interface.Cam.FieldOfView | |
local targetFOV = args[2] | |
local frames = args[3] | |
local Alpha = args[4] | |
local currentTrans = (Interface.Scope.BackgroundTransparency == 1 and (S.guiScope and 0 or 1) or Interface.Scope.BackgroundTransparency) | |
local t0 = TICK() | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local X = MIN((TICK() - t0) / frames, 1) * 90 | |
if currentFOV > targetFOV then | |
aimAlpha = Alpha(X) | |
else | |
aimAlpha = 1 - Alpha(X) | |
end | |
aimHeadOffset = headOffset.X * aimAlpha | |
jumpAnimMultiplier = GunMath.numLerp(1, S.fallSettings.aimEffect, aimAlpha) | |
translationDivisor = GunMath.numLerp(7, 20, aimAlpha) | |
rotationMultiplier = GunMath.numLerp(S.momentumSettings.Amplitude.unAimed, S.momentumSettings.Amplitude.Aimed, aimAlpha) | |
armTiltMultiplier = GunMath.numLerp(1, 0.2, aimAlpha) | |
local lerpedTrans = (currentFOV > targetFOV and GunMath.numLerp(currentTrans, 0, aimAlpha) or GunMath.numLerp(1, currentTrans, aimAlpha)) | |
Interface.Cam.FieldOfView = (currentFOV > targetFOV and GunMath.numLerp(currentFOV,targetFOV,aimAlpha) or GunMath.numLerp(targetFOV,currentFOV,aimAlpha) ) | |
if currentFOV > targetFOV then | |
if not Aimed then break end | |
else if Aimed then break end | |
end | |
if Gun.BlackScope.Value then | |
Interface.Scope.BackgroundTransparency = lerpedTrans | |
end | |
if X == 90 then break end | |
if (not Selected) then break end | |
end | |
elseif args[1] == "Bolt" then | |
runAsync(function() | |
local key = args[2] | |
local newKick = args[3] | |
local newRot = args[4] | |
local Alpha = args[5] | |
local Duration = args[6] | |
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 | |
Services.RS.RenderStepped:wait() | |
local newX = X + Increment | |
X = (newX > 90 and 90 or newX) | |
if boltAnim[key].Code ~= newCode then break end | |
if (not Selected) then break end | |
boltAnim[key].Kick = prevKick:lerp(newKick, Alpha(X)) | |
boltAnim[key].Rot = prevRot:lerp(newRot, Alpha(X)) | |
if X == 90 then break end | |
end | |
if boltAnim[key].Code == newCode then | |
boltAnim[key].Code = nil | |
end | |
end) | |
end | |
end | |
--------------------[ GUI UPDATE FUNCTIONS ]------------------------------------------ | |
local function updateGUI(...) | |
local args = {...} | |
if args[1] == "ClipAmmo" then | |
clipAmmoGUI.Text = Ammo.Value .. "|" .. getMagCount(ClipSize.Value,"estimated") | |
clipAmmoGUI.TextColor3 = (Ammo.Value <= (ClipSize.Value / 3) and C3(1, 0, 0) or C3(1, 1, 1)) | |
if AmmoBar then | |
AmmoBar.Size = UDIM2((Ammo.Value/ClipSize.Value),0,1,0) | |
end | |
elseif args[1] == "Grenades" then | |
Interface.HUD.Grenades.Lethals.Num.Text = Gun.LethalGrenades.Value | |
Interface.HUD.Grenades.Tacticals.Num.Text = Gun.TacticalGrenades.Value | |
elseif args[1] == "ModeLabels" then | |
fireModes.FireModeController:JumpTo(fireModes[args[2] - 1]) | |
elseif args[1] == "Cartridge" then | |
if Services.UIS.TouchEnabled then | |
Interface.HUD.Cartridge.Text = CurrentCartridge.Title | |
else | |
Interface.HUD.Cartridge.Main.Text = CurrentCartridge.Title | |
end | |
elseif args[1] == "ClipAmmo:Preload" then | |
for i = 3, 5 do | |
wait(S.reloadSettings.Times.Loaded/3) | |
if clipAmmoGUI then | |
clipAmmoGUI.Text = string.rep("-",i) | |
end | |
end | |
end | |
end | |
--------------------[ GUI SETUP FUNCTION ]-------------------------------------------- | |
function setUpGUI() | |
local currentNum = 1 | |
if Gun.BlackScope.Value then | |
scopeSteady.Text = "Hold Left-Shift to Steady" | |
bindableService.send("SetScopeUI",Gun.ScopeId.Value ~= "" and Gun.ScopeId.Value or bindableService.fetch("GetScopeUI")) | |
end | |
tween("textTrans",clipAmmoGUI,0,Sine,0.33333333333333) | |
INSERT(Connections, Ammo.Changed:connect(function(ammo) | |
updateGUI("ClipAmmo") | |
end)) | |
if not Services.UIS.TouchEnabled then | |
clipAmmoGUI:TweenPosition(UDIM2(0.5,0,0,0),"Out", "Bounce", 1) | |
end | |
updateGUI("ClipAmmo") | |
updateGUI("Grenades") | |
Interface.HUD.Grenades.Lethals.Icon.Image = Interface.LethalIcons[S.grenadeSettings.Lethal.Type] | |
Interface.HUD.Grenades.Tacticals.Icon.Image = Interface.TacticalIcons[S.grenadeSettings.Tactical.Type] | |
create("Modes") | |
updateGUI("ModeLabels",numModes - 1, 0, 90) | |
modeGUI.Text = (S.selectFire and Modes[rawFireMode] or S.defaultMode:upper()) | |
end | |
--------------------[ CAMERA RENDERING FUNCTIONS ]----------------------------------- | |
local function changePlayerTrans(P, Trans) | |
for _, v in pairs(P:GetChildren()) do | |
if v:IsA("BasePart") and (not v:IsDescendantOf(Gun)) then | |
runAsync(function() | |
v.LocalTransparencyModifier = Trans | |
end) | |
end | |
runAsync(function() | |
changePlayerTrans(v, Trans) | |
end) | |
end | |
end | |
GunMath.getYawPitch = function(Cf) | |
local LV = Cf.lookVector | |
local Yaw = ATAN2(LV.x, -LV.z) | |
local Pitch = ATAN(LV.y / ((LV.x ^ 2) + (LV.z ^ 2)^0.5)) | |
return Yaw, Pitch | |
end | |
GunMath.getTotalCamOffset = function() | |
return camOffsets.guiScope.Rot + camOffsets.Reload.Rot + camRecoilSpring.p | |
end | |
--------------------[ ANIMATION FUNCTIONS ]------------------------------------------- | |
--local function gunbob(a,r) | |
-- local a,r=a or 1,r or 1 | |
-- local d,s,v=char.distance*6.28318*3/4,char.speed,-char.velocity | |
-- local w=v3(r*sin(d/4-1)/256+r*(sin(d/64)-r*v.z/4)/512,r*cos(d/128)/128-r*cos(d/8)/256,r*sin(d/8)/128+r*v.x/1024)*s/20*6.28318 | |
-- return cf(r*cos(d/8-1)*s/196,1.25*a*sin(d/4)*s/512,0)*cframe.fromaxisangle(w) | |
-- end | |
local WalkSpeeds = { | |
[0] = function(SpeedRatio) | |
return V3.RAW((Aimed and S.walkSpeeds.Aimed or S.walkSpeeds.Base),0,0) | |
end; | |
[1] = function(SpeedRatio) | |
return V3.RAW((Aimed and S.walkSpeeds.Crouched * SpeedRatio or S.walkSpeeds.Crouched),0,0) | |
end; | |
[2] = function(SpeedRatio) | |
return V3.RAW((Aimed and S.walkSpeeds.Prone * SpeedRatio or S.walkSpeeds.Prone),0,0) | |
end; | |
} | |
local function getCrossPositions(newS) | |
return { | |
UDIM2(0.5, -1, 1, -newS * 0.5); | |
UDIM2(0, newS * 0.5 - 15, 0.5, -1); | |
UDIM2(0.5, -1, 0, newS * 0.5 - 15); | |
UDIM2(1, -newS * 0.5, 0.5, -1); | |
}; | |
end | |
function Animate() | |
local Increment = 90 * 2.5 --1.5 / 0.4 | |
local runAlpha = 0 | |
local currentlyCrawling = false | |
local crawlTween = false | |
INSERT(Connections, Services.RS.Heartbeat:connect(function(dt) | |
--Movement Variable updating | |
isCrawling = (Stance == 2 and onGround and S.stanceSettings.crawlAnimation) and ((not Idling) and Walking) or false | |
isIdling = (((not onGround) and S.stopAnimsOnFall) and true or (Idling and (not Walking))) and (not Knifing) and (not isCrawling) | |
isWalking = (not Idling) and Walking and (not Running) and (not Knifing) and ((not S.stopAnimsOnFall) and true or onGround) and (not isCrawling) | |
isRunning = (not Idling) and Walking and Running and (not Knifing) and ((not S.stopAnimsOnFall) and true or onGround) and (not isCrawling) | |
crawlAlpha = MIN(MAX(crawlAlpha + (isCrawling and Increment or -Increment) * dt, 0), 90) | |
idleAlpha = MIN(MAX(idleAlpha + (isIdling and Increment or -Increment) * dt, 0), 90) | |
walkAlpha = MIN(MAX(walkAlpha + (isWalking and Increment or -Increment) * dt, 0), 90) | |
runAlpha = MIN(MAX(runAlpha + (isRunning and Increment or -Increment) * dt, 0), 90) | |
local posHip = ( | |
Sine(idleAlpha) * (Libraries.Anims.Idling["unAimed"](Anim.Ang)).Pos | |
) + ( | |
Sine(walkAlpha) * (Libraries.Anims.Walking["unAimed"](Anim.Ang)).Pos | |
) + ( | |
Sine(runAlpha) * (Libraries.Anims.Running(Anim.Ang)).Pos | |
) | |
local rotHip = ( | |
Sine(idleAlpha) * (Libraries.Anims.Idling["unAimed"](Anim.Ang)).Rot | |
) + ( | |
Sine(walkAlpha) * (Libraries.Anims.Walking["unAimed"](Anim.Ang)).Rot | |
) + ( | |
Sine(runAlpha) * (Libraries.Anims.Running(Anim.Ang)).Rot | |
) | |
local posAim = ( | |
Sine(idleAlpha) * (Libraries.Anims.Idling["Aimed"](Anim.Ang)).Pos | |
) + ( | |
Sine(walkAlpha) * (Libraries.Anims.Walking["Aimed"](Anim.Ang)).Pos | |
) + ( | |
Sine(runAlpha) * (Libraries.Anims.Running(Anim.Ang)).Pos | |
) | |
local rotAim = ( | |
Sine(idleAlpha) * (Libraries.Anims.Idling["Aimed"](Anim.Ang)).Rot | |
) + ( | |
Sine(walkAlpha) * (Libraries.Anims.Walking["Aimed"](Anim.Ang)).Rot | |
) + ( | |
Sine(runAlpha) * (Libraries.Anims.Running(Anim.Ang)).Rot | |
) | |
Anim.Pos = (1 - aimAlpha) * posHip + aimAlpha * posAim | |
Anim.Rot = (1 - aimAlpha) * rotHip + aimAlpha * rotAim | |
Anim.Ang = Anim.Ang + RAD(105 * dt) * stanceSway | |
--Gun Momentum updating | |
gunMomentum.t = V3.RAW(desiredXOffset, desiredYOffset, 0) | |
local newGunMomentum = gunMomentum.p | |
currentXOffset = newGunMomentum.X / S.momentumSettings.maxInput | |
currentYOffset = newGunMomentum.Y / S.momentumSettings.maxInput | |
--Recoil spring updating | |
gunRecoilSpring.t = recoilAnim.Rot | |
camRecoilSpring.t = camOffsets.Recoil.Rot | |
--Cross spring updating | |
crossSpring.t = (Aimed and V3.RAW(-2, 0, 0) or V3.RAW(crossOffset + (baseSpread + currentSpread) * 50, 0, 0)) | |
local newS = crossSpring.p.X*crossScale.p.X*(Humanoid.WalkSpeed/14*(1-0.8)*2+0.8)*((Running and 1 or 0)+1)/4 | |
local crossPos = getCrossPositions(newS) | |
if not S.gunType.Shot then | |
for i, v in pairs(crossParts) do | |
v.Position = crossPos[i]; | |
end | |
end | |
--Orientation updating | |
local finalCamOffset = GunMath.getTotalCamOffset() | |
headWeld.C1 = CF.ANG(-camAng.y - finalCamOffset.Y, 0, 0) | |
Libraries.Network.send("Server","changeHeadC1_"..Player.UserId,headWeld,headWeld.C1) | |
if (not Humanoid.Sit) then | |
HRP.CFrame = CF.RAW(HRP.Position) * CF.ANG(0, camAng.x + finalCamOffset.X, 0) | |
headWeld.C1 = CF.ANG(-camAng.y - finalCamOffset.Y, 0, 0) | |
else | |
local HRPDir = CF.RAW(HRP.Position) * CF.RAW(HRP.Position,Humanoid.TargetPoint).lookVector | |
HRP.CFrame = CF.RAW(HRP.Position,HRP.Position + HRPDir) | |
HRP.CFrame = CF.RAW(HRP.Position) * CF.ANG(0, camAng.x + finalCamOffset.X, 0) | |
headWeld.C1 = CF.ANG(0 + (-camAng.y - finalCamOffset.Y) ,0,0) | |
end | |
--Walkspeed updating | |
if Running then | |
walkSpeedSpring.t = V3.RAW(S.walkSpeeds.Sprinting,0,0) | |
else | |
local SpeedRatio = S.walkSpeeds.Aimed / S.walkSpeeds.Base | |
walkSpeedSpring.t = WalkSpeeds[Stance](SpeedRatio) | |
end | |
Humanoid.WalkSpeed = walkSpeedSpring.p.X | |
end)) | |
local crawlAng = 0 | |
while Selected do | |
if isCrawling then | |
breakReload = (Reloading and true or breakReload) | |
if Aimed then unAimGun(true) end | |
local tempCrawlAnim = Libraries.Anims.Crawling(crawlAng, moveAng) | |
tween("Crawl",tempCrawlAnim,false) | |
tween("Joint",ArmWelds.LWeld, nil, tempCrawlAnim.leftArm, Linear, 0.3) | |
tween("Joint",ArmWelds.RWeld, nil, tempCrawlAnim.rightArm, Linear, 0.3) | |
tween("Joint",Grips.Right, nil, tempCrawlAnim.Grip, Linear, 0.3) | |
lowerSpread() | |
local t0 = TICK() | |
while true do | |
local dt = Services.RS.Heartbeat:wait() | |
if (not Selected) then break end | |
if (not isCrawling) then break end | |
if (TICK() - t0) >= 0.3 then | |
local crawlAnim = Libraries.Anims.Crawling(crawlAng, moveAng) | |
ArmWelds.RWeld.C1 = crawlAnim.rightArm | |
ArmWelds.RWeld.C1 = crawlAnim.rightArm | |
ArmWelds.LWeld.C1 = crawlAnim.leftArm | |
LLegWeld.C1 = crawlAnim.leftLeg | |
RLegWeld.C1 = crawlAnim.rightLeg | |
Grips.Right.C1 = crawlAnim.Grip | |
Libraries.Network.send("Server","changeLLegWeldC1_"..Player.UserId,LLegWeld,LLegWeld.C1) | |
Libraries.Network.send("Server","changeRLegWeldC1_"..Player.UserId,RLegWeld,RLegWeld.C1) | |
Libraries.Network.send("Server","changeGripC1_"..Player.UserId,Grips.Right,Grips.Right.C1) | |
Libraries.Network.send("Server","changeLWeldC1_"..Player.UserId,ArmWelds.LWeld,ArmWelds.LWeld.C1) | |
Libraries.Network.send("Server","changeRWeldC1_"..Player.UserId,ArmWelds.RWeld,ArmWelds.RWeld.C1) | |
crawlCamRot = crawlAnim.Camera | |
CameraService.CurrentModeVars:SetCrawlCamRot(crawlCamRot) | |
crawlAng = crawlAng + 0.5 * RAD(105 * dt) * (HRP.Velocity * V3.RAW(1, 0, 1)).magnitude * 0.333333333 | |
end | |
end | |
else | |
crawlAng = 0 | |
if (not equipAnimPlaying) then | |
local tempCrawlAnim = Libraries.Anims.Crawling(crawlAng, moveAng) | |
tween("Crawl",tempCrawlAnim,true) | |
if (not isRunning) then | |
tween("Joint",ArmWelds.LWeld, nil, S.unAimedC1.leftArm, Sine, 0.3) | |
tween("Joint",ArmWelds.RWeld, nil, S.unAimedC1.rightArm, Sine, 0.3) | |
tween("Joint",Grips.Right, nil, S.unAimedC1.Grip, Sine, 0.3) | |
end | |
end | |
while true do | |
if (not Selected) then break end | |
if isCrawling then break end | |
shortWait(Services.RS.Heartbeat) | |
end | |
end | |
wait() | |
end | |
end | |
function getAnimCF(t,...) | |
if t == "General" then | |
return CF.RAW(aimHeadOffset, 0, 0) * CF.ANG( | |
jumpAnim.Rot * COS(camAng.Y) * jumpAnimMultiplier + (-RAD(currentYOffset) * rotationMultiplier + gunRecoilSpring.p.X + Anim.Rot.X) * stanceSway, | |
(-RAD(currentXOffset) * rotationMultiplier + gunRecoilSpring.p.Y + Anim.Rot.Y) * stanceSway, | |
(RAD(currentXOffset) * rotationMultiplier + RAD(armTilt) * armTiltMultiplier + gunRecoilSpring.p.Z + Anim.Rot.Z) * stanceSway | |
) * CF.RAW( | |
(Anim.Pos.X + recoilAnim.Pos.X) * stanceSway, | |
jumpAnim.Pos * COS(camAng.Y) * jumpAnimMultiplier + (Anim.Pos.Y + recoilAnim.Pos.Y) * stanceSway, | |
-jumpAnim.Pos * SIN(camAng.Y) * jumpAnimMultiplier + (Anim.Pos.Z + recoilAnim.Pos.Z) * stanceSway | |
) - CameraService.currentShakeCF.p, CF.ANG(-camAng.Y * crawlAlpha * 0.01111111, 0, 0) * CF.RAW(aimHeadOffset, -1, 0) | |
elseif t == "Bolt" then | |
local args = {...} | |
local key = args[1] | |
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 | |
--------------------[ FIRING FUNCTIONS ]---------------------------------------------- | |
function lowerSpread() | |
if (not loweringSpread) then | |
loweringSpread = true | |
local Connection = nil | |
Connection = Services.RS.Heartbeat:connect(function(dt) | |
if MB1Down 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 | |
function getFiringFunction(ammoType) | |
local fireGun = function() | |
local fireSound = FFC(getFirePort(1),"FireSound") | |
tween("Bolt","Main",S.boltSettings.Kick,S.boltSettings.Rot,Sine,0.05) | |
if fireSound then | |
if S.fireSoundSettings then | |
if S.fireSoundSettings.useSoundRemover then | |
local fireSoundC = fireSound:Clone() | |
fireSoundC.Parent = getFirePort(1) | |
fireSoundC:Play() | |
fireSoundC.Ended:connect(function() | |
fireSoundC:Destroy() | |
end) | |
else | |
fireSound.TimePosition = S.fireSoundSettings.Start | |
SoundLib.Play(fireSound) | |
end | |
else | |
SoundLib.Play(fireSound) | |
end | |
end | |
---------------------------------------------------------------------------------- | |
for _ = 1, (S.gunType.Shot and S.shotAmount or 1) do | |
local spreadDir | |
if S.gunType.Shot then | |
local randSpread1 = RAD(GunMath.RAND(0, 365)) | |
local randSpread2 = RAD(GunMath.RAND(-(baseSpread + currentSpread), baseSpread + currentSpread, 0.01)) | |
spreadDir = CF.FAxA(V3.RAW(0, 0, 1) * randSpread1) * CF.ANG(randSpread2, 0, 0) | |
end | |
local originCF = ((Aimed and S.guiScope) and Head.CFrame or Handle.CFrame) | |
if spreadDir then | |
originCF = originCF | |
end | |
local bulletDirection = CF.RAW(originCF.p, originCF.p + originCF.lookVector).lookVector | |
if CurrentCartridge.InstantHit then | |
local newRay | |
if S.guiScope then | |
newRay = Interface.Cam:ScreenPointToRay(VantagePoint.AbsolutePosition.X,VantagePoint.AbsolutePosition.Y,0) | |
newRay = RAY.RAW(newRay.Origin,newRay.Direction * CurrentCartridge.Range) | |
else | |
newRay = RAY.RAW(getFirePort(1).CFrame.p, bulletDirection * CurrentCartridge.Range) | |
end | |
local H, P, N = RAY.CAST(Services.WS,newRay, Ignore) | |
local finalP = P | |
if H then | |
if S.gunType.Explosive then | |
Libraries.Network.send("Server","FireExplosive_"..Player.UserId,gunIgnore,H,P,N,bulletDirection,Ignore,getFirePort(1)) | |
else | |
_, finalP = penetrateWall(H, P, bulletDirection, N, {Char, ignoreModel}, 0, (P - getFirePort(1).CFrame.p).magnitude, nil) | |
end | |
end | |
if S.bulletTrail and S.trailSettings.Transparency ~= 1 then | |
Libraries.Network.fetch("Server","Trail_"..Player.UserId,getFirePort(1).CFrame.p, finalP, gunIgnore, S) | |
end | |
else | |
local bullet = create("Bullet",bulletDirection,1) | |
--Gun.BulletObj.Value = bullet | |
local debounceParts = {} | |
bullet.Touched:connect(function(hit) | |
if (not debounceParts[hit]) and (bullet.CFrame.p - getFirePort(1).CFrame.p).magnitude <= CurrentCartridge.Range then | |
debounceParts[hit] = true | |
local newRay = RAY.RAW(getFirePort(1).CFrame.p, (bullet.CFrame.p - getFirePort(1).CFrame.p)) | |
local H, P, N = Services.WS:FindPartOnRayWithIgnoreList(newRay, {Char, ignoreModel}) | |
local finalP = P | |
if S.gunType.Explosive then | |
if (not hit:isDescendantOf(Char) and not hit:isDescendantOf(ignoreModel)) and not isWallIgnored(hit) then | |
Libraries.Network.send("Server","FireExplosive",gunIgnore,hit,P,N,bulletDirection,Ignore,getFirePort(1)) | |
OBJ.Destroy(bullet) | |
end | |
else | |
if (not hit:isDescendantOf(Char) and not hit:isDescendantOf(ignoreModel)) and not isWallIgnored(hit) then | |
makeHole(hit, P, N, bulletDirection, false, S.roundsPerMin) | |
penetrateWall(hit, P, bullet.CFrame.lookVector, N, {Char, ignoreModel}, 0, (bullet.CFrame.p - getFirePort(1).CFrame.p).magnitude, nil) | |
--penetrateWall(H, P, bulletDirection, N, {Char, ignoreModel}, 0, (P - Main.CFrame.p).magnitude, nil) | |
if (bullet.CFrame.p - 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 = GunMath.RAND(S.recoilSettings.Recoil.Back.Min, S.recoilSettings.Recoil.Back.Max, 0.01) --Get the kickback recoil | |
local upRecoil = GunMath.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 = GunMath.RAND(0, 1, 0.1) | |
elseif lastSideRecoil[1] > 0 and lastSideRecoil[2] > 0 then | |
sideRecoilAlpha = GunMath.RAND(-1, 0, 0.1) | |
else | |
sideRecoilAlpha = GunMath.RAND(-1, 1, 0.1) | |
end | |
local sideRecoil = GunMath.numLerp(S.recoilSettings.Recoil.Side.Left, S.recoilSettings.Recoil.Side.Right, sideRecoilAlpha / 2 + 0.5) --Get the side recoil | |
local tiltRecoil = GunMath.numLerp(S.recoilSettings.Recoil.Tilt.Left, S.recoilSettings.Recoil.Tilt.Right, sideRecoilAlpha / 2 + 0.5) --Get the tilt recoil | |
local recoilPos = V3.RAW( | |
0,---sideRecoil, | |
0, | |
-backRecoil | |
) * (Aimed and S.recoilSettings.aimedMultiplier or 1) | |
local recoilRot = V3.RAW( | |
(Aimed and 0 or (-RAD(upRecoil * 10) * (firstShot and S.recoilSettings.firstShotMultiplier or 1))), | |
RAD(sideRecoil * 10), | |
RAD(tiltRecoil * 10) | |
) * (Aimed and S.recoilSettings.aimedMultiplier or 1) | |
local camRecoilRot = V3.RAW( | |
-RAD(sideRecoil * 10), | |
RAD(upRecoil * 10) * (firstShot and S.recoilSettings.firstShotMultiplier or 1) * S.recoilSettings.camMultiplier, | |
0 | |
) * (Aimed and S.recoilSettings.aimedMultiplier or 1) * stanceSway | |
Libraries.Haptics.Recoil(1,Player) | |
tween("Recoil",recoilPos, recoilRot, Sine, 0.2) | |
tween("Cam","Recoil", camRecoilRot, Sine, 0.15 * (firstShot and S.recoilSettings.firstShotMultiplier or 1)) | |
if S.isRevolver then | |
revolverMagParts[(ClipSize.Value - Ammo.Value)].Transparency = 1 | |
tween("Joint",Gun.RHPart.CarouselMotor,nil,CF.ANG(0,RAD(-72 * (ClipSize.Value - Ammo.Value)),0),Linear,0.4) | |
end | |
for _, v in pairs(getFirePort(1):GetChildren()) do | |
if v.Name:find("FlashFX") then | |
v.Enabled = true | |
end | |
end | |
Libraries.Network.send("Server","MuzzleFlash",getFirePort(1)) | |
delay(0.05, function() | |
Libraries.Haptics.Recoil(2,Player) | |
tween("Recoil",V3.ID, V3.ID, Sine, 0.2) | |
tween("Cam","Recoil", V3.ID, Sine, 0.2) | |
tween("Bolt","Main",V3.RAW(),V3.RAW(),Sine,0.2) | |
for _, v in pairs(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.cockingAnim then | |
if S.isSniperRifle then | |
repeat shortWait(Services.RS.Heartbeat) until not Aimed | |
end | |
playAnimation("Cocking") | |
end | |
end | |
local fireGrenade = function() | |
local Cartridge = Libraries.Cartridges[Gun.GrenadeCaliber.Value] | |
playSound("rbxassetid://135039581",2) | |
local randSpread1 = RAD(GunMath.RAND(0, 365)) | |
local randSpread2 = RAD(GunMath.RAND(-(baseSpread + currentSpread), baseSpread + currentSpread, 0.01)) | |
local spreadDir = CF.FAxA(V3.RAW(0, 0, 1) * randSpread1) * CF.ANG(randSpread2, 0, 0) | |
local originCF = ((Aimed and S.guiScope) and Head.CFrame or Handle.CFrame) * spreadDir | |
local bulletDirection = CF.RAW(originCF.p, originCF.p + originCF.lookVector).lookVector | |
if Cartridge.InstantHit then | |
local newRay | |
if S.guiScope then | |
newRay = Interface.Cam:ScreenPointToRay(VantagePoint.AbsolutePosition.X,VantagePoint.AbsolutePosition.Y,0) | |
newRay = RAY.RAW(newRay.Origin,newRay.Direction * Cartridge.Range) | |
else | |
newRay = RAY.RAW(getFirePort(2).CFrame.p, bulletDirection * Cartridge.Range) | |
end | |
local H, P, N = RAY.CAST(Services.WS,newRay, Ignore) | |
local finalP = P | |
if H then | |
if S.gunType.Explosive then | |
Libraries.Network.send("Server","FireExplosive_"..Player.UserId,gunIgnore,H,P,N,bulletDirection,Ignore) | |
else | |
_, finalP = penetrateWall(H, P, bulletDirection, N, {Char, ignoreModel}, 0, (P - getFirePort(2).CFrame.p).magnitude, nil) | |
end | |
end | |
if S.bulletTrail and S.trailSettings.Transparency ~= 1 then | |
Libraries.Network.fetch("Server","Trail_"..Player.UserId,getFirePort(2).CFrame.p, finalP, gunIgnore, S) | |
end | |
else | |
local bullet = create("Bullet",modeGUI.Text,bulletDirection,2) | |
--Gun.BulletObj.Value = bullet | |
local debounceParts = {} | |
bullet.Touched:connect(function(hit) | |
if (not debounceParts[hit]) and (bullet.CFrame.p - getFirePort(2).CFrame.p).magnitude <= Cartridge.Range then | |
debounceParts[hit] = true | |
local newRay = RAY.RAW(getFirePort(2).CFrame.p, (bullet.CFrame.p - getFirePort(2).CFrame.p)) | |
local H, P, N = Services.WS:FindPartOnRayWithIgnoreList(newRay, {Char, ignoreModel}) | |
local finalP = P | |
if (not hit:isDescendantOf(Char) and not hit:isDescendantOf(ignoreModel)) and not isWallIgnored(hit) then | |
Libraries.Network.send("Server","FireExplosive",gunIgnore,hit,P,N,bulletDirection,Ignore,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 = GunMath.RAND(S.recoilSettings.Recoil.Back.Min, S.recoilSettings.Recoil.Back.Max, 0.01) --Get the kickback recoil | |
local upRecoil = GunMath.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 = GunMath.RAND(0, 1, 0.1) | |
elseif lastSideRecoil[1] > 0 and lastSideRecoil[2] > 0 then | |
sideRecoilAlpha = GunMath.RAND(-1, 0, 0.1) | |
else | |
sideRecoilAlpha = GunMath.RAND(-1, 1, 0.1) | |
end | |
local sideRecoil = GunMath.numLerp(S.recoilSettings.Recoil.Side.Left, S.recoilSettings.Recoil.Side.Right, sideRecoilAlpha / 2 + 0.5) --Get the side recoil | |
local tiltRecoil = GunMath.numLerp(S.recoilSettings.Recoil.Tilt.Left, S.recoilSettings.Recoil.Tilt.Right, sideRecoilAlpha / 2 + 0.5) --Get the tilt recoil | |
local recoilPos = V3.RAW( | |
0,---sideRecoil, | |
0, | |
-backRecoil | |
) * (Aimed and S.recoilSettings.aimedMultiplier or 1) | |
local recoilRot = V3.RAW( | |
(Aimed and 0 or (-RAD(upRecoil * 10) * (firstShot and S.recoilSettings.firstShotMultiplier or 1))), | |
RAD(sideRecoil * 10), | |
RAD(tiltRecoil * 10) | |
) * (Aimed and S.recoilSettings.aimedMultiplier or 1) | |
local camRecoilRot = V3.RAW( | |
-RAD(sideRecoil * 10), | |
RAD(upRecoil * 10) * (firstShot and S.recoilSettings.firstShotMultiplier or 1) * S.recoilSettings.camMultiplier, | |
0 | |
) * (Aimed and S.recoilSettings.aimedMultiplier or 1) * stanceSway | |
Libraries.Haptics.Recoil(1,Player) | |
recoilAnim.Pos = recoilPos | |
recoilAnim.Rot = recoilRot | |
camOffsets.Recoil = camRecoilRot | |
for _, v in pairs(getFirePort(2):GetChildren()) do | |
if v.Name:find("FlashFX") then | |
v.Enabled = true | |
end | |
end | |
Libraries.Network.send("Server","MuzzleFlash",getFirePort(2)) | |
delay(0.05, function() | |
Libraries.Haptics.Recoil(2,Player) | |
tween("Recoil",V3.ID, V3.ID, Sine, 0.2) | |
tween("Cam","Recoil", V3.ID, Sine, 0.2) | |
for _, v in pairs(getFirePort(2):GetChildren()) do | |
if v.Name:find("FlashFX") then | |
v.Enabled = false | |
end | |
end | |
end) | |
firstShot = false | |
shotCount = shotCount + 1 | |
lastSideRecoil[(shotCount % 2) + 1] = sideRecoilAlpha | |
end | |
if ammoType == "Cartridge" then | |
return fireGun | |
elseif ammoType == "Grenade" then | |
return fireGrenade | |
end | |
end | |
local function fire() | |
local firingApi = { | |
currentFireMode = function() | |
return Modes[rawFireMode]; | |
end; | |
setCanFire = function(bool) | |
canFire = bool | |
end; | |
getCanFire = function() | |
return canFire | |
end; | |
setFiring = function(bool) | |
Firing = bool | |
end; | |
Knifing = Knifing; | |
isCrawling = isCrawling; | |
Reloading = function() | |
return Reloading | |
end; | |
MB1Down = function() | |
return MB1Down; | |
end; | |
Ammo = Ammo; | |
Lethals = Gun.LethalGrenades; | |
Click = function() | |
if Ammo.Value <= 0 then | |
playSound("rbxassetid://131242822") | |
end | |
end; | |
Humanoid = Humanoid; | |
useAmmo = function() | |
Ammo.Value = Ammo.Value - 1; | |
end; | |
useLethal = function() | |
Gun.LethalGrenades.Value = Gun.LethalGrenades.Value - 1 | |
updateGUI("Grenades") | |
end; | |
unSteadyCam = function() | |
if Aimed and steadyKeyPressed and S.scopeSettings.unSteadyOnFire then | |
steadyKeyPressed = false | |
currentSteadyTime = 0 | |
end | |
end; | |
setNewMag = function(bool) | |
newMag = bool | |
end; | |
fireGun = getFiringFunction("Cartridge"); | |
fireGrenade = getFiringFunction("Grenade"); | |
fireMag = function() | |
if S.reloadSettings.magIsBullet then | |
for _, Mag in pairs(Gun: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) | |
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) | |
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 | |
} | |
local modeOfFire = Libraries.Firemodes[firingApi.currentFireMode()] | |
if modeOfFire then | |
modeOfFire(firingApi) | |
end | |
end | |
--------------------[ ADS FUNCTIONS ]------------------------------------------------- | |
function aimGun() | |
if Reloading or Knifing or isCrawling or (not S.canADS) then return end | |
Sensitivity.mouse = Sensitivity.aim | |
for i = 1,#Libraries.Plugins.Aimed do | |
runAsync(function() | |
Libraries.Plugins.Aimed[i](Player) | |
end) | |
end | |
Aimed = true | |
Aiming = true | |
Running = false | |
spreadZoom = "Aimed" | |
baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion] | |
if S.aimSettings.Anim then | |
tween("Joint",ArmWelds.LWeld, armC0[1], S.aimedC1.leftArm, Sine, S.aimSettings.Speed) | |
tween("Joint",ArmWelds.RWeld, armC0[2], S.aimedC1.rightArm, Sine, S.aimSettings.Speed) | |
tween("Joint",LWeld2, nil, CF.RAW(), Sine, S.aimSettings.Speed) | |
tween("Joint",RWeld2, nil, CF.RAW(), Sine, S.aimSettings.Speed) | |
tween("Joint",Grips.Right, nil, aimedGripCF(AimPart), Sine, S.aimSettings.Speed) | |
tween("Joint",headWeld2, nil, CF.RAW(0, -0.5, 0) * CF.ANG(0, 0, S.aimSettings.headTilt) * CF.RAW(0, 0.5, 0), Sine, S.aimSettings.Speed) | |
tween("Aim",Gun.FOV.Value,S.aimSettings.Speed,Sine) | |
else | |
ArmWelds.LWeld.C0, ArmWelds.LWeld.C1 = armC0[1], S.aimedC1.leftArm | |
ArmWelds.RWeld.C0, ArmWelds.RWeld.C1 = armC0[2], S.aimedC1.rightArm | |
LWeld2.C1, RWeld2.C1 = CF.RAW(), CF.RAW() | |
animWeld.C0 = CF.RAW(0, 1, 0) | |
Grips.Right.C1 = aimedGripCF(AimPart) | |
headWeld2.C1 = CF.RAW(0, -0.5, 0) * CF.ANG(0, 0, S.aimSettings.headTilt) * CF.RAW(0, 0.5, 0) | |
aimAlpha = 1 | |
aimHeadOffset = headOffset.X | |
jumpAnimMultiplier = S.fallSettings.aimEffect | |
translationDivisor = 20 | |
rotationMultiplier = S.momentumSettings.Amplitude.Aimed | |
armTiltMultiplier = 0.2 | |
Interface.Cam.FieldOfView = Gun.FOV.Value | |
end | |
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 = (Sine(idleAlpha) * idleCam()) + (Sine(walkAlpha) * walkCam()) | |
camAng = camAng + RAD(105 * dt) * stanceSway * camSway | |
end | |
end) | |
end | |
end | |
function unAimGun(Exception) | |
if (not S.canADS) then return end | |
Sensitivity.mouse = RemoteService.fetch("Server","GetSensitivity","Gun") | |
for _, Plugin in PAIRS(Libraries.Plugins.UnAimed) do | |
runAsync(function() | |
Plugin() | |
end) | |
end | |
if Gun.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 | |
fakeLArm.LocalTransparencyModifier = 0 | |
fakeRArm.LocalTransparencyModifier = 0 | |
if (not Exception) then | |
if (not Aimed) then return end | |
if (Reloading and Exception) or Knifing then return end | |
spreadZoom = "unAimed" | |
baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion] | |
Aimed = false | |
Aiming = true | |
if S.aimSettings.Anim then | |
local currentFOV = Interface.Cam.FieldOfView | |
scopeMain.Visible = false | |
scopeSteady.Visible = false | |
tween("Joint",ArmWelds.LWeld, armC0[1], S.unAimedC1.leftArm, Sine, S.aimSettings.Speed) | |
tween("Joint",ArmWelds.RWeld, armC0[2], S.unAimedC1.rightArm, Sine, S.aimSettings.Speed) | |
tween("Joint",headWeld2, nil, CF.RAW(), Sine, S.aimSettings.Speed) | |
tween("Joint",Grips.Right, nil, S.unAimedC1.Grip, Sine, S.aimSettings.Speed) | |
tween("Aim",S.aimSettings.OutFOV,S.aimSettings.Speed,Sine) | |
Interface.HUD.Visible = true | |
else | |
scopeMain.Visible = false | |
scopeSteady.Visible = false | |
ArmWelds.LWeld.C0, ArmWelds.LWeld.C1 = armC0[1], S.unAimedC1.leftArm | |
ArmWelds.RWeld.C0, ArmWelds.RWeld.C1 = armC0[2], S.unAimedC1.rightArm | |
headWeld2.C0 = CF.RAW() | |
Grips.Right.C1 = S.unAimedC1.Grip | |
aimAlpha = 0 | |
aimHeadOffset = 0 | |
jumpAnimMultiplier = 1 | |
translationDivisor = 7 | |
rotationMultiplier = S.momentumSettings.Amplitude.unAimed | |
armTiltMultiplier = 1 | |
Interface.Cam.FieldOfView = 80 | |
Interface.Scope.BackgroundTransparency = 1 | |
Interface.HUD.Visible = true | |
end | |
Aiming = Aimed | |
else | |
runAsync(function() | |
Aimed = false | |
Aiming = false | |
spreadZoom = "unAimed" | |
baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion] | |
local currentFOV = Interface.Cam.FieldOfView | |
scopeMain.Visible = false | |
scopeSteady.Visible = false | |
tween("Joint",headWeld2, nil, CF.RAW(), Sine, S.aimSettings.Speed) | |
if S.aimSettings.Anim then | |
tween("Aim",S.aimSettings.OutFOV,S.aimSettings.Speed,Quad) | |
else | |
scopeMain.Visible = false | |
scopeSteady.Visible = false | |
aimAlpha = 0 | |
aimHeadOffset = 0 | |
jumpAnimMultiplier = 1 | |
translationDivisor = 7 | |
rotationMultiplier = S.momentumSettings.Amplitude.unAimed | |
armTiltMultiplier = 1 | |
Interface.Cam.FieldOfView = S.aimSettings.OutFOV | |
Interface.Scope.BackgroundTransparency = 1 | |
end | |
end) | |
end | |
end | |
function makeHole(H,P,N,D,humanoidFound) | |
local surfaceCF =CF.RAW(P,P + N) | |
local HitSounds = { | |
"285421759"; | |
"151130102"; | |
"151130171"; | |
"285421804"; | |
"287769483"; | |
"287769415"; | |
"285421687"; | |
"287769261"; | |
"287772525"; | |
"287772445"; | |
"287772351"; | |
"285421819"; | |
"287772163"; | |
} | |
if not H then return end | |
---------------------------------------------------------------------------------- | |
--Creating the bullet hole-------------------------------------------------------- | |
---------------------------------------------------------------------------------- | |
local Hole = OBJ.RAW("Part") | |
Hole.Transparency = 1 | |
Hole.Anchored = true | |
Hole.CanCollide = false | |
Hole.Size = V3.RAW(1, 1, 0.2) | |
Hole.TopSurface = 0 | |
Hole.BottomSurface = 0 | |
if ((not humanoidFound)) then | |
local Decal = OBJ.RAW("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.RAW("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------------------------------------------------------- | |
---------------------------------------------------------------------------------- | |
Libraries.Network.send("Server","bulletImpact_"..Player.UserId,H, P, N, D, humanoidFound, gunIgnore) | |
end | |
--------------------[ TEXTURE CREATION FUNCTIONS ]------------------------------------ | |
function createBullet(Direction,index) | |
local Origin = getFirePort(index).CFrame.p | |
local bulletCF = CF.RAW(Origin, Origin + Direction) | |
local Bullet = OBJ.RAW("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.RAW('Attachment') | |
TrailFront.Position = V3.RAW(0.1, 0, 0) | |
TrailFront.Parent = Bullet | |
local TrailBack = OBJ.RAW('Attachment') | |
TrailBack.Position = V3.RAW(-0.1, 0, 0) | |
TrailBack.Parent = Bullet | |
local Trail = OBJ.RAW('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.RAW ("VectorForce") | |
BF.Attachment0 = TrailFront | |
BF.RelativeTo = Enum.ActuatorRelativeTo.World | |
BF.Force = V3.RAW(0, Bullet:GetMass() * (196.2 - CurrentCartridge.Acceleration), 0) | |
BF.Parent = Bullet | |
Bullet.Parent = gunIgnore | |
Bullet.CFrame = bulletCF + Direction * CurrentCartridge.Size.Z / 2 | |
Bullet.Velocity = Direction * CurrentCartridge.Velocity | |
Libraries.Network.send("Server","ReplicateBullet_"..Player.UserId,Direction,Bullet.CFrame,CurrentCartridge.Name) | |
return Bullet | |
end | |
--------------------[ HIT HANDLING FUNCTIONS ]---------------------------------------- | |
function getBaseDamage(Dist) | |
local startDmg = S.damageSettings.Start.Damage | |
local startDist = S.damageSettings.Start.Dist | |
local endDmg = S.damageSettings.End.Damage | |
local endDist = S.damageSettings.End.Dist | |
return ( | |
( | |
Dist < startDist * CurrentCartridge.Range | |
) and startDmg or | |
( | |
Dist >= startDist * CurrentCartridge.Range and | |
Dist < endDist * CurrentCartridge.Range | |
) and GunMath.numLerp(startDmg, endDmg, GunMath.Map(Dist / CurrentCartridge.Range, startDist, endDist, 0, 1)) or | |
( | |
Dist >= endDist * CurrentCartridge.Range | |
) and endDmg | |
) | |
end | |
local function DamageVehicle(part,Dist) | |
local h = nil | |
local t = nil | |
if part.Parent.ClassName == "Model" then | |
for i,v in pairs(part.Parent:GetChildren()) do | |
if v.Name == "Health" and v.ClassName == "IntValue" then | |
h = v | |
t = part.Parent:FindFirstChild("Team") | |
end | |
end | |
end | |
if part.Parent.Parent.ClassName == "Model" then | |
for i,v in pairs(part.Parent.Parent:GetChildren()) do | |
if v.Name == "Health" and v.ClassName == "IntValue" then | |
h = v | |
t = part.Parent.Parent:FindFirstChild("Team") | |
end | |
end | |
end | |
if h and t then | |
local curh = h.Value | |
if curh - getBaseDamage(Dist) > 0 then | |
h.Value = h.Value - getBaseDamage(Dist) | |
elseif curh - getBaseDamage(Dist) <=0 then | |
h.Value = 0 | |
end | |
end | |
end | |
function Damage(H, P, N, D, Dist, customIgnore) | |
Libraries.Network.doDamage(Humanoid, H, P, N, D, Dist, customIgnore, CurrentCartridge.Name) | |
end | |
function isWallIgnored(Wall) | |
return ( | |
Wall.Transparency >= S.penetrationSettings.transparencyThreshold or | |
(S.penetrationSettings.ignoreNonCanCollide and (not Wall.CanCollide)) or | |
isIgnored(Wall, S.penetrationSettings.ignoreCustom) | |
) | |
end | |
function CreateSound(id, volume, pitch) | |
local s = Instance.new("Sound") | |
s.SoundId = "http://www.roblox.com/asset/?id="..id | |
s.Volume = volume | |
s.Pitch = pitch | |
return s | |
end | |
function playSound(id, volume, pitch, playbackSpeed) | |
local Sound = Handle: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 | |
function penetrateWall(Wall, hitPos, Direction, Normal, Ignore, totalPDist, totalBDist, lastDamagedHumanoid) | |
local wallIgnore = isWallIgnored(Wall) | |
local hitHumanoid = Damage(Wall, hitPos, Normal, Direction, totalBDist, {Char, ignoreModel}) | |
local damagedHumanoid = nil | |
if hitHumanoid and hitHumanoid ~= lastDamagedHumanoid then | |
lastDamagedHumanoid = hitHumanoid | |
damagedHumanoid = Damage(Wall, hitPos, Normal, Direction, totalBDist, {Char, ignoreModel}) | |
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 | |
INSERT(Ignore, ignoreObject) | |
local rayLength = CurrentCartridge.Range - totalBDist | |
local testRay = RAY.RAW(hitPos, Direction * (CurrentCartridge.Range - totalBDist)) | |
local H1, P1, N1 = RAY.CAST(Services.WS,testRay, Ignore) | |
local newIgnore = removeElement(Ignore, ignoreObject) | |
local wallRay = RAY.RAW(P1 + Direction * 0.1, -Direction * (rayLength + 1)) | |
local H2, P2, N2 = RAY.CAST(Services.WS,wallRay, Ignore) | |
local newPDist = totalPDist + (wallIgnore and 0 or (GunMath.getNearestPoint(P1, P2, hitPos) - hitPos).magnitude) | |
local newBDist = totalBDist + (P1 - hitPos).magnitude | |
local outOfRange = GunMath.Round(newPDist, 0.001) > S.penetrationSettings.Dist or GunMath.Round(newBDist, 0.001) > CurrentCartridge.Range | |
if (not wallIgnore) then | |
makeHole(Wall, P2, N2, Direction, hitHumanoid, gunIgnore, S) | |
if (not hitHumanoid) then | |
Libraries.Network.send("Server","Shockwave_"..Player.UserId,hitPos, S.shockwaveSettings.Radius, gunIgnore, S) | |
end | |
end | |
if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) and hitHumanoid == damagedHumanoid then | |
Libraries.Network.fetch("Server","Blood_"..Player.UserId,Wall, P2, Direction, gunIgnore, S) | |
end | |
if outOfRange or (not H1) then | |
if (not outOfRange) and (not wallIgnore) and modeGUI.Text ~= "STUN" then | |
makeHole(Wall, P2, N2, Direction, hitHumanoid, gunIgnore, S) | |
if (not hitHumanoid) then | |
Libraries.Network.send("Server","Shockwave_"..Player.UserId,P2, S.shockwaveSettings.Radius, gunIgnore, S) | |
end | |
end | |
if Wall:FindFirstAncestor("Fragmentables") then | |
RemoteService.send("Server","BreakWindow",Wall) | |
end | |
return Wall, hitPos | |
else | |
if Wall == H2 and (not wallIgnore) and modeGUI.Text ~= "STUN" then | |
makeHole(Wall, P2, N2, Direction, hitHumanoid, gunIgnore, S) | |
if (not hitHumanoid) then | |
Libraries.Network.send("Server","Shockwave_"..Player.UserId,P2, S.shockwaveSettings.Radius, gunIgnore, S) | |
end | |
end | |
if Wall:FindFirstAncestor("Fragmentables") then | |
RemoteService.send("Server","BreakWindow",Wall) | |
end | |
PenetrationTries = PenetrationTries - 1 | |
if PenetrationTries ~= 0 then | |
return penetrateWall(H1, P1, Direction, N1, Ignore, newPDist, newBDist, lastDamagedHumanoid) | |
else | |
PenetrationTries = S.penetrationSettings.maxTries | |
return nil | |
end | |
end | |
end | |
function isEnemy(Human) | |
local Plyr2 = game.Players:GetPlayerFromCharacter(Human.Parent) | |
if (not Plyr2) then | |
if S.CanDamageNPCs then | |
if Human.Parent:FindFirstChild("BOT") then | |
return (require(Human.Parent.BOT).Team ~= Player.Team) | |
end | |
end | |
end | |
return S.AllowFriendlyFire or (Plyr2 ~= nil and (Plyr2.Team ~= Player.Team or Plyr2.Neutral)) | |
end | |
--------------------[ Animation Functions ]---------------------------------------------- | |
local function isClimbing() | |
local tracks = Humanoid:GetPlayingAnimationTracks() | |
if tracks then | |
for _, track in pairs(tracks) do | |
local animation = track.Animation | |
if animation.AnimationId:find("180436334") then | |
return true | |
end | |
end | |
end | |
return false | |
end | |
function playAnimation(animName,...) | |
tween("Joint",LWeld2, CF.RAW(), CF.RAW(), Sine, 0.15) | |
tween("Joint",RWeld2, CF.RAW(), CF.RAW(), Sine, 0.15) | |
local magParts = {} | |
local magTable = {} | |
local grenadeTable = {} | |
local spottedTarget = nil; | |
local args = {...} | |
local magCaseVisible = false | |
for _, Obj in pairs(Gun:GetChildren()) do | |
if Obj.Name:sub( 1, 3) == "Mag" and Obj:IsA("BasePart") then | |
INSERT(magParts, Obj) | |
end | |
end | |
if S.isRevolver then | |
table.sort(magParts,function(a,b) | |
return a.Name == "MagCase" | |
end) | |
end | |
local GType = nil | |
if animName == "Nading" then | |
GType = args[1] | |
end | |
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 animVars = { | |
--FUNCTIONS-- | |
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; | |
tweenBolt = function(Key, Kick, Rot, Alpha, Duration) | |
tween("Bolt", Key, Kick, Rot, Alpha, Duration) | |
end; | |
boltBack = function(alpha,duration) | |
tween("Bolt", S.boltSettings.Kick, S.boltSettings.Rot, alpha, 0.1) | |
delay(duration,function() | |
tween("Bolt", V3.RAW(), V3.RAW(), alpha, 0.1) | |
end) | |
end; | |
captureTarget = function(...) | |
local args = {...} | |
local spotRay = Ray.new(CameraService.Cam.CFrame.p,CameraService.Cam.CFrame.lookVector * 500) | |
local T, L, N = workspace:FindPartOnRayWithIgnoreList(spotRay,args) | |
if T then | |
if T.Parent then | |
local ParentHum = T.Parent:FindFirstChildOfClass("Humanoid") | |
if ParentHum and isEnemy(ParentHum) then | |
spottedTarget = ParentHum.Parent | |
elseif T.Parent:FindFirstAncestor("Vault") then | |
spottedTarget = T | |
end | |
end | |
end | |
end; | |
processSpot = function() | |
if spottedTarget then | |
local order = {} | |
if spottedTarget:FindFirstChildOfClass("Humanoid") then | |
order.Type = "EliminateEnemy"; | |
order.Target = spottedTarget | |
elseif spottedTarget:FindFirstAncestor("Vault") then | |
order.Type = "OpenVault"; | |
order.Target = spottedTarget:FindFirstAncestor("Vault").Door | |
end | |
bindableService.send("CreateAutoOrder",order) | |
end | |
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 | |
Gun.Bolt.Transparency = 1 | |
end | |
magVisible = false | |
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 | |
Gun.Bolt.Transparency = 0 | |
end | |
magVisible = true | |
end; | |
preloadAmmoUI = function() | |
spawn(function() | |
updateGUI("ClipAmmo:Preload") | |
end) | |
end; | |
isMagVisible = function() | |
return magVisible | |
end; | |
isMagEmpty = function() | |
return ammoInClip == 0 | |
end; | |
setNewMag = function() | |
newMag = true | |
end; | |
isNewMag = function() | |
return newMag | |
end; | |
repeatUntilReloaded = function(repetition) | |
for i = Ammo.Value, Ammo.Value <= ClipSize.Value and (ClipSize.Value + 1) or ClipSize.Value do | |
repetition() | |
Ammo.Value =i | |
updateGUI("ClipAmmo") | |
end | |
end; | |
createMag = function(Key,transparent) | |
local magModel = OBJ.RAW("Model") | |
local magClones = {} | |
local magRevolverCase = nil; | |
for i, v in PAIRS(magParts) do | |
local vClone = OBJ.Clone(v) | |
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 | |
INSERT(magClones, {Original = v, magClone = vClone}) | |
if i ~= 1 then | |
if not S.isRevolver then | |
local W = OBJ.RAW("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.RAW("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 boltClone = Gun.Bolt:Clone() | |
local boltWeld2 = OBJ.RAW("Motor6D") | |
boltWeld2.Part0 = magClones[1].magClone | |
boltWeld2.Part1 = boltClone | |
boltWeld2.C0 = CF.TOS(magClones[1].magClone.CFrame,boltClone.CFrame) | |
boltWeld2.Parent = magClones[1].magClone | |
boltClone.Parent = Gun | |
end | |
end | |
magTable[Key] = {magModel, magClones} | |
if magRevolverCase then | |
INSERT(magTable[Key],magRevolverCase) | |
end | |
return magModel, magClones, magRevolverCase | |
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; | |
getMagInsertionCFrame = function(LC1,RC1,GC1,magClones) | |
local LArmCF, RArmCF, handleOffsetCF, originalMagOffsetCF = CF.RAW(),CF.RAW(),CF.RAW(),CF.RAW() | |
local newMagCF = CF.RAW() | |
if LC1 then | |
LArmCF = ArmBase.CFrame *ArmWelds.LWeld.C0 *(LC1):inverse() | |
end | |
if RC1 then | |
RArmCF = ArmBase.CFrame * ArmWelds.RWeld.C0 * (RC1):inverse() | |
end | |
if GC1 then | |
local gripArm = currentGripArm() | |
handleOffsetCF = gripArm.CFrame:toObjectSpace(gripArm.CFrame * Grips.Right.C0 *(GC1):inverse()) | |
end | |
if magClones then | |
originalMagOffsetCF = Handle.CFrame:toObjectSpace(magClones[1].Original.CFrame) | |
end | |
local gArm = currentGripArm() | |
if gArm == RArm then | |
newMagCF = LArmCF:toObjectSpace(RArmCF * handleOffsetCF * originalMagOffsetCF) | |
elseif gArm == LArm then | |
newMagCF = RArmCF:toObjectSpace(LArmCF * handleOffsetCF * originalMagOffsetCF) | |
end | |
return newMagCF | |
end; | |
makeRevolverMagCaseVisible = function(key) | |
if magTable[key] then | |
local mag = magTable[key] | |
if mag[3] then | |
magCaseVisible = true | |
mag[3].Transparency = 0 | |
end | |
end | |
end; | |
attachGripToHead = function() | |
local handleCF = RArm.CFrame * Grips.Right.C0 | |
Grips.Right.C0 = CF.TOS(Head.CFrame,handleCF) | |
Grips.Right.Part0 = Head | |
end; | |
attachGripToArm = function(armType) | |
if armType == "Left" then | |
Grips.Left.Part0 = LArm | |
local HandleCF = Handle.CFrame | |
Grips.Left.Part1 = Handle | |
Grips.Right.Part0 = nil | |
Grips.Left.C0 = LArm.CFrame:toObjectSpace(HandleCF) | |
Grips.Current = "Left" | |
else | |
Grips.Left.Part0 = nil | |
Grips.Right.Part0 = RArm | |
Grips.Right.Part1 = Handle | |
Grips.Current = "Right" | |
end | |
end; | |
detachAndResetGrip = function(C1) | |
Grips.Right.Part0 = RArm | |
if C1 then | |
Grips.Right.C1 = C1 | |
end | |
end; | |
addVaultForce = function() | |
local bp=Instance.new("BodyPosition") | |
bp.position=HRP.Position+HRP.CFrame.lookVector.unit*Humanoid.WalkSpeed/1.5+V3.RAW(0,2.5,0) | |
bp.maxForce=V3.RAW(5000000, 5000000, 5000000) | |
bp.P=4000 | |
bp.Parent = HRP; | |
delay(0.45,function() | |
bp:Destroy() | |
end) | |
end; | |
ejectShell = function() | |
local shell = game.ReplicatedStorage.GunEffectAssets.Shell:Clone() | |
shell.CFrame = Gun.Chamber.CFrame | |
shell.Velocity = Gun.Chamber.CFrame.lookVector * 30 + Vector3.new(0,4,0) | |
shell.RotVelocity = Vector3.new(-10,40,30) | |
shell.Parent = workspace.ShellIgnore | |
return shell | |
end; | |
RHMotor = function() | |
if S.isRevolver then | |
return Gun.RHPart:FindFirstChild("RevolverHinge") | |
end | |
return nil | |
end; | |
Carousel = function() | |
if S.isRevolver then | |
return Gun:FindFirstChild("Carousel") | |
end | |
return nil | |
end; | |
DumpPart = function() | |
if S.isRevolver then | |
return Gun:FindFirstChild("DumpPart") | |
end | |
return nil | |
end; | |
detachCarouselMotor = function() | |
if S.isRevolver then | |
if Gun.RHPart:FindFirstChild("CarouselMotor") then | |
Gun.RHPart.CarouselMotor.Part1 = nil | |
end | |
end | |
end; | |
createRevolverWeld = function() | |
local RevolverBarrelWeld2 = Instance.new("Motor6D") | |
RevolverBarrelWeld2.Name = "CarouselAttachment" | |
RevolverBarrelWeld2.Part0 = Gun.RevolverHinge | |
RevolverBarrelWeld2.Part1 = Gun.Carousel | |
RevolverBarrelWeld2.C0 = Gun.RevolverHinge.CFrame:toObjectSpace(Gun.Carousel.CFrame) | |
RevolverBarrelWeld2 .Parent = Gun.RevolverHinge | |
return RevolverBarrelWeld2 | |
end; | |
isAimed = function() | |
return Aimed | |
end; | |
playSound = playSound; | |
Pump = function() | |
if S.isPumpActionShotgun then | |
return Gun:FindFirstChild("Pump") | |
end | |
return nil | |
end; | |
LidHinge = function() | |
if S.isLMG then | |
return Gun.LidEffector:FindFirstChild("LidHinge"); | |
end | |
return nil | |
end; | |
PumpSlide = function() | |
if S.isPumpActionShotgun then | |
return Gun.PumpPart:FindFirstChild("PumpSlide") | |
end | |
return nil | |
end; | |
startingLC1 = function() | |
return Aimed and S.aimedC1.leftArm or S.unAimedC1.leftArm | |
end; | |
FRArm = armModel:FindFirstChild("Right Arm"); | |
FLArm = armModel:FindFirstChild("Left Arm"); | |
attachGripToTorso = function(C1) | |
Grips.Right.Part0 = Torso | |
if C1 then | |
Grips.Right.C1 = C1 | |
end | |
end; | |
waitForInputRelease = function() | |
if GType == 1 then | |
repeat wait() until not Services.UIS:IsKeyDown(Enum.KeyCode.G) | |
else | |
repeat wait() until not (Services.UIS:IsKeyDown(Enum.KeyCode.T) and Services.UIS:IsKeyDown(Enum.KeyCode.LeftShift)) | |
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; | |
setNadeCFrameRemote = function(nade, nadeCF) | |
RemoteService.send("Server","SetNadeCF",nade,nadeCF) | |
end; | |
createGrenadeRemote = function(Name,weldNade) | |
local nade | |
if S.grenadeSettings.Lethal.Type == 3 and GType == 1 then | |
nade = Libraries.Network.fetch("Server","CreateKnifeGrenade",RArm,weldNade,Grips.Right.C0,CF.RAW(0, 0, -0.5) * CF.ANG(RAD(90), RAD(90), 0)) | |
else | |
nade = Libraries.Network.fetch("Server","CreateGrenade",GType,weldNade,armModel:FindFirstChild("Right Arm"),Grips.Right.C0) | |
end | |
grenadeTable[Name] = nade | |
return nade, Name | |
end; | |
createGrenade = function(Name,weldNade) | |
local nade | |
local Grenade | |
if GType == 1 then | |
if S.grenadeSettings.Lethal.Type == 1 then | |
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Frag"):Clone() | |
elseif S.grenadeSettings.Lethal.Type == 4 then | |
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Molotov"):Clone() | |
elseif S.grenadeSettings.Lethal.Type == 2 then | |
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Sticky"):Clone() | |
end | |
elseif GType == 2 then | |
if S.grenadeSettings.Tactical.Type == 1 then | |
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Smoke"):Clone() | |
elseif S.grenadeSettings.Tactical.Type == 2 then | |
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Flashbang"):Clone() | |
end | |
end | |
Grenade:SetPrimaryPartCFrame(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 = RArm | |
Weld.Part1 = Grenade:WaitForChild("Center") | |
Weld.C0 = 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 Head.CFrame | |
end; | |
playNadeSound = function(sound,Parent) | |
local Sound = Instance.new("Sound") | |
Sound.SoundId = sound | |
Sound.Volume = 1 | |
Sound.Parent = Parent | |
end; | |
nadeIsA = function(nadeType) | |
local nadetypes = { | |
[1] = { | |
["Frag"] = 1; | |
["Sticky"] = 2; | |
["ThrowingKnife"] = 3; | |
["Molotov"] = 4; | |
}; | |
[2] = { | |
["Smoke"] = 1; | |
["Flashbang"] = 2; | |
}; | |
} | |
local returnType | |
if GType == 1 then | |
returnType = S.grenadeSettings.Lethal.Type; | |
elseif GType == 2 then | |
returnType = S.grenadeSettings.Tactical.Type; | |
end | |
return nadetypes[GType][nadeType] == returnType; | |
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; | |
sheatheGun = function() | |
Grips.Right.Part0 = nil | |
SheatheWeld = Instance.new("Motor6D") | |
SheatheWeld.Part0 = HRP | |
SheatheWeld.Parent = SheatheWeld.Part0 | |
SheatheWeld.Part1 = Handle | |
if guntype == 1 then | |
if weldmode == 1 then | |
SheatheWeld.C1 = CF.RAW(distance *-1, 0.25 +y, -0.75 +x *-1) * CF.ANG(RAD(rotation *-1), (math.pi / 2), 0) | |
elseif weldmode == 2 then | |
SheatheWeld.C1 = CF.RAW(distance, 0.25 +y, -0.75 +x *-1) * CF.ANG(RAD(rotation *-1), (math.pi / 2 ) *-1, 0) | |
elseif weldmode == 3 then | |
SheatheWeld.C1 = CF.RAW(distance *-1, -0.1+y, 0.2 +x *-1) * CF.ANG(RAD(rotation), (math.pi / 2), -1.5) | |
elseif weldmode == 4 then | |
SheatheWeld.C1 = CF.RAW(distance, 0.25+y, -0.75 +x *-1) * CF.ANG(RAD(rotation), (math.pi / 2 +rotation) *-1.1, 1) | |
end | |
elseif guntype == 2 then | |
if weldmode == 1 then | |
SheatheWeld.C1 = CF.RAW(distance *-1, 0.25+y, -0.5 +x *-1) * CF.ANG(RAD(rotation *-1), math.pi / 2, 0) | |
elseif weldmode == 2 then | |
SheatheWeld.C1 = CF.RAW(distance, 0.25 +y, -0.5 +x *-1) * CF.ANG(RAD(rotation *-1), math.pi / 2 *-1, 0) | |
elseif weldmode == 3 then | |
SheatheWeld.C1 = CF.RAW(distance *-1, 0.25 +y, -0.5 +x *-1) * CF.ANG(RAD(rotation), math.pi / 2, 0) | |
elseif weldmode == 4 then | |
SheatheWeld.C1 = CF.RAW(distance, 0.25 +y, -0.5 +x *-1) * CF.ANG(RAD(rotation), math.pi / 2 *-1, 0) | |
end | |
elseif guntype == 3 then | |
if weldmode == 1 then | |
SheatheWeld.C1 = CF.RAW(distance *-1, 0 +y, -0.25 +x *-1) * CF.ANG(math.pi / 2, 0, 0) | |
elseif weldmode == 2 then | |
SheatheWeld.C1 = CF.RAW(distance, 0 +y, -0.25 +x *-1) * CF.ANG(math.pi / 2, 0, 0) | |
elseif weldmode == 3 then | |
SheatheWeld.C1 = CF.RAW(distance *-1, 0 +y, 0.25 +x) * CF.ANG(math.pi / 2 , math.pi / 2, 0) | |
elseif weldmode == 4 then | |
SheatheWeld.C1 = CF.RAW(distance, 0 +y, 0.25 +x) * CF.ANG(math.pi / 2 , math.pi / 2 *-1, 0) | |
end | |
end | |
end; | |
unSheatheGun = function() | |
if SheatheWeld then | |
SheatheWeld:Destroy() | |
end | |
Grips.Right.Part0 = RArm | |
end; | |
climbingSpeed = function() | |
return Humanoid.WalkSpeed * 0.7 / Humanoid.WalkSpeed | |
end; | |
isMoving = function() | |
local velocity = Torso.CFrame:vectorToObjectSpace(Torso.Velocity) | |
return (ABS(velocity.Y) > 0.2) | |
end; | |
vaultPart = function() | |
return args[1]; | |
end; | |
getGrenadeType = function() | |
return GType | |
end; | |
Sine = Sine; | |
Quad = Quad; | |
QuadOut = QuadOut; | |
Linear = Linear; | |
--VARIABLES-- | |
Handle = Handle; | |
LArm = LArm; | |
RArm = RArm; | |
Torso = Torso; | |
LWeld = ArmWelds.LWeld; | |
RWeld = ArmWelds.RWeld; | |
LWeld2 = LWeld2; | |
RWeld2 = RWeld2; | |
LC0 = armC0[1]; | |
RC0 = armC0[2]; | |
LGrip = Grips.Left; | |
RGrip = Grips.Right; | |
Grip = Grips[Grips.Current]; | |
BoltExtents = S.boltSettings.Kick; | |
gunIgnore = gunIgnore; | |
Cam = Interface.Cam; | |
CF = CF.RAW; | |
CFANG = CF.ANG; | |
V3 = V3.RAW; | |
RAD = RAD; | |
Player = Player; | |
IgnoreList = Ignore; | |
reloadTimeLoaded = S.reloadSettings.Times.Loaded; | |
reloadTimeEmpty = S.reloadSettings.Times.Empty; | |
inspectTime = S.inspectTime; | |
lNadeType = S.grenadeSettings.Lethal.Type; | |
throwVelocity = S.grenadeSettings.Lethal.throwVelocity; | |
throwVelocityTactical = S.grenadeSettings.Tactical.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; | |
} | |
if animName == "Reload" then | |
for pluginName,pluginResult in PAIRS(Libraries.Plugins.ReloadAnimPlugins) do | |
animVars[pluginName] = pluginResult(Libraries[Libraries.Plugins.ReloadAnimPluginData[pluginName]]) | |
end | |
end | |
local sequenceTable = Libraries.Anims[animName](animVars) | |
--local T = TICK() | |
for _, animFunction in PAIRS(sequenceTable) do | |
if breakReload and animName == "Reload" then | |
break | |
end | |
animFunction() | |
if (not magVisible) and animName == "Reload" then | |
Ammo.Value = 0 | |
end | |
end | |
clipAmmoGUI.Text = Ammo.Value | |
--print(TICK() - T) --I divide the reloadTime by this number to get the animation speed | |
if not animName:find("Climbing") then | |
if (not isCrawling) then | |
if Running and (not S.canFireWhileRunning) then | |
tween("Joint",ArmWelds.LWeld, armC0[1], S.runningC1.leftArm, Sine, 0.4) | |
tween("Joint",ArmWelds.RWeld, armC0[2], S.runningC1.rightArm, Sine, 0.4) | |
tween("Joint",Grips.Right, nil, S.runningC1.Grip, Sine, 0.4) | |
else | |
tween("Joint",ArmWelds.LWeld, armC0[1], S.unAimedC1.leftArm, Sine, 0.4) | |
tween("Joint",ArmWelds.RWeld, armC0[2], S.unAimedC1.rightArm, Sine, 0.4) | |
tween("Joint",Grips.Right, nil, S.unAimedC1.Grip, Sine, 0.4) | |
end | |
end | |
end | |
tween("Recoil",V3.ID,V3.ID,Sine,0.4) | |
for _, v in PAIRS(magTable) do --In case the reload animations was stopped mid way and there were still fake mags that weren't deleted | |
OBJ.Destroy(v[1]) | |
end | |
delay(4,function() | |
for _, v in pairs(grenadeTable) do | |
OBJ.Destroy(v) | |
end | |
end) | |
end | |
function Climb() | |
-- playAnimation("ClimbingStart") | |
-- repeat | |
-- playAnimation("ClimbingLoop") | |
-- wait() | |
-- until | |
-- not isClimbing() | |
-- print("ClimbEnd") | |
-- playAnimation("ClimbingEnd") | |
-- if (not isCrawling) then | |
-- if Running and (not S.canFireWhileRunning) then | |
-- tween("Joint",ArmWelds.LWeld, armC0[1], S.runningC1.leftArm, Sine, 0.4) | |
-- tween("Joint",ArmWelds.RWeld, armC0[2], S.runningC1.rightArm, Sine, 0.4) | |
-- tween("Joint",Grip, nil, S.runningC1.Grip, Sine, 0.4) | |
-- else | |
-- tween("Joint",ArmWelds.LWeld, armC0[1], S.unAimedC1.leftArm, Sine, 0.4) | |
-- tween("Joint",ArmWelds.RWeld, armC0[2], S.unAimedC1.rightArm, Sine, 0.4) | |
-- tween("Joint",Grip, nil, S.unAimedC1.Grip, Sine, 0.4) | |
-- end | |
-- end | |
end | |
function Reload() | |
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 | |
lowerSpread() | |
if Aimed then unAimGun(S.reloadSettings.Anim) end | |
if FFC(Handle,"ReloadSound") then Handle.ReloadSound:Play() end | |
runAsync(function() | |
end) | |
if S.reloadSettings.Anim then | |
wait() | |
playAnimation("Reload") | |
updateGUI("ClipAmmo") | |
else | |
local startReload = TICK() | |
local initialReloadTime = Ammo.Value == 0 and S.reloadSettings.Times.Empty or S.reloadSettings.Times.Loaded | |
while true do | |
if breakReload then break end | |
if (TICK() - startReload) >= initialReloadTime then break end | |
shortWait(Services.RS.Heartbeat) | |
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 Selected then | |
ammoInClip = (breakReload and ammoInClip or 0) | |
end | |
breakReload = false | |
end | |
end | |
Libraries.Network.listen("Client","Send","Reload",Reload) | |
--------------------[ EXTERNAL DATA LOCATING FUNCTIONS ]----------------------------- | |
function removeElement(Table, Element) --removes the first instance of Element from Table | |
for i, v in PAIRS(Table) do | |
if v == Element then | |
REMOVE(Table, i) | |
break | |
end | |
end | |
return Table | |
end | |
function isIgnored(Obj, Table) | |
for _,v in PAIRS(Table) do | |
if Obj == v or Obj:IsDescendantOf(v) then | |
return true | |
end | |
end | |
return false | |
end | |
function AdvRayCast(Origin, Direction, Dist, CustomIgnore) | |
local NewIgnore = (CustomIgnore and CustomIgnore or Ignore) | |
local NewRay = RAY.RAW(Origin, Direction * (Dist > 999 and 999 or Dist)) | |
local HitObj, HitPos, HitNorm = RAY.CAST(Services.WS,NewRay, NewIgnore) | |
local LastPos = HitPos | |
local FinalHitObj, FinalHitPos = nil, nil | |
local RepTimes = FLOOR(Dist * 0.001001001) | |
if (not HitObj) and (Dist > 999) then | |
for i = 0, RepTimes do | |
local NewDist = (i == RepTimes and (Dist - (LastPos - Origin).magnitude) or 999) | |
local Ray2 = RAY.RAW(LastPos, Direction * NewDist) | |
local HitObj2, HitPos2 = RAY.CAST(Services.WS,Ray2, NewIgnore) | |
if i ~= RepTimes then | |
if HitObj2 then | |
FinalHitObj, FinalHitPos = HitObj2, HitPos2 | |
break | |
end | |
elseif i == RepTimes then | |
FinalHitObj, FinalHitPos = HitObj2, HitPos2 | |
end | |
LastPos = HitPos2 | |
end | |
return FinalHitObj, FinalHitPos | |
elseif HitObj or (Dist <= 999) then | |
return HitObj, HitPos, HitNorm | |
end | |
end | |
--------------------[ JUMPING ANIMATION ]--------------------------------------------- | |
function onFall(initialVelocity) | |
runAsync(function() | |
local velocityAlpha = MAX(MIN(initialVelocity / Humanoid.JumpPower, 1), 0) | |
local startJumpPos = jumpAnim.Pos | |
local startJumpRot = jumpAnim.Rot | |
local endJumpPos = 0.04 * S.fallSettings.fallMultiplier * velocityAlpha | |
local endJumpRot = RAD(4) * S.fallSettings.fallMultiplier * velocityAlpha | |
local t0 = TICK() | |
while true do | |
Services.RS.Heartbeat:wait() | |
local Alpha = MIN((TICK() - t0) * 6.66666667, 1) * 90 | |
if onGround then break end | |
jumpAnim.Pos = GunMath.numLerp(startJumpPos, endJumpPos, Sine(Alpha)) | |
jumpAnim.Rot = GunMath.numLerp(startJumpRot, endJumpRot, Sine(Alpha)) | |
if Alpha == 90 then break end | |
end | |
startJumpPos = endJumpPos | |
startJumpRot = endJumpRot | |
endJumpPos = -0.08 * S.fallSettings.fallMultiplier | |
endJumpRot = -RAD(8) * S.fallSettings.fallMultiplier | |
local X = 1 | |
while true do | |
local dt = Services.RS.Heartbeat:wait() | |
X = X + (dt * 60) / X | |
local Alpha = (X - 1) * 0.0666667 | |
if onGround then break end | |
jumpAnim.Pos = GunMath.numLerp(startJumpPos, endJumpPos, Alpha) | |
jumpAnim.Rot = GunMath.numLerp(startJumpRot, endJumpRot, Alpha) | |
end | |
end) | |
end | |
function onLand(fallDist) | |
runAsync(function() | |
local animAlpha = MIN(fallDist, S.fallSettings.maxDist) * (0.6666667) | |
local startJumpPos = jumpAnim.Pos | |
local startJumpRot = jumpAnim.Rot | |
local endJumpPos = animAlpha * 0.01 * S.fallSettings.landMultiplier * (runReady and 1 or 2) | |
local endJumpRot = RAD(animAlpha) * S.fallSettings.landMultiplier * (runReady and 1 or 2) | |
local t0 = TICK() | |
while true do | |
Services.RS.Heartbeat:wait() | |
local Alpha = MIN((TICK() - t0) * 5, 1) | |
if (not onGround) then break end | |
jumpAnim.Pos = GunMath.numLerp(startJumpPos, endJumpPos, Alpha) | |
jumpAnim.Rot = GunMath.numLerp(startJumpRot, endJumpRot, Alpha) | |
if Alpha == 1 then break end | |
end | |
t0 = TICK() | |
while true do | |
Services.RS.Heartbeat:wait() | |
local Alpha = MIN((TICK() - t0) * 30, 1) * 90 | |
if (not onGround) then break end | |
jumpAnim.Pos = GunMath.numLerp(endJumpPos, 0, Sine(Alpha)) | |
jumpAnim.Rot = GunMath.numLerp(endJumpRot, 0, Sine(Alpha)) | |
if Alpha == 90 then break end | |
end | |
end) | |
end | |
function onHumanoidStateChanged(oldState, newState) | |
if newState == Enum.HumanoidStateType.Freefall then | |
onGround = false | |
if S.fallAnimation then | |
onFall(HRP.Velocity.Y) | |
while HRP.Velocity.Y > 0 do shortWait(Services.RS.RenderStepped) end | |
startFallHeight = HRP.Position.Y | |
end | |
elseif oldState == Enum.HumanoidStateType.Freefall then | |
onGround = true | |
if S.fallAnimation then | |
local fallDist = startFallHeight - HRP.Position.Y | |
onLand(fallDist) | |
end | |
end | |
end | |
--------------------[ CAMERA STEADYING FUNCTIONS ]------------------------------------ | |
function steadyCamera() | |
scopeSteady.Text = "Steadying..." | |
scopeSteady.TextColor3 = C3(1, 1, 1) | |
camSteady = true | |
local originalSway = camSway | |
local Increment = 1.5 / 0.6 | |
local X = 0 | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local newX = X + Increment | |
X = (newX > 90 and 90 or newX) | |
if (not steadyKeyPressed) then break end | |
camSway = GunMath.numLerp(originalSway, 0, Sine(X)) | |
if X == 90 then break end | |
end | |
while steadyKeyPressed and Aimed do | |
if Stamina > 0 then | |
Stamina = RemoteService.fetch("Server","DecrementStamina",0.5) | |
scopeSteady.Full.Bar.Size = UDIM2((1 - (Stamina/maxStamina)),0,1,0) | |
camSway = 0 | |
elseif Stamina <= 0 then | |
break | |
end | |
shortWait(Services.RS.Heartbeat) | |
end | |
camSteady = false | |
runAsync(function() | |
local Increment = 1.5 * 4 | |
local X = 0 | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local newX = X + Increment | |
X = (newX > 90 and 90 or newX) | |
if camSteady then break end | |
camSway = GunMath.numLerp(0, S.scopeSettings.camSwayOnBreath, 1 - COS(RAD(X))) | |
if X == 90 then break end | |
end | |
Increment = 1.5 / S.scopeSettings.breathTime | |
X = 0 | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local newX = X + Increment | |
X = (newX > 90 and 90 or newX) | |
if camSteady then break end | |
camSway = GunMath.numLerp(S.scopeSettings.camSwayOnBreath, 1, Sine(X)) | |
if X == 90 then break end | |
end | |
--[[for X = 0, 90, 1.5 / 0.2 do | |
local Alpha = 1 - COS(RAD(X))--math.log10(X) / math.log10(90) | |
camSway = GunMath.numLerp(0, 3, Alpha) | |
RS.RenderStepped:wait() | |
end]] | |
--[[for X = 0, 90, 1.5 / S.scopeSettings.steadyTime do | |
if camSteady then break end | |
local Alpha = SIN(RAD(X)) | |
camSway = numLerp(3, 1, Alpha) | |
RS.RenderStepped:wait() | |
end]] | |
end) | |
retakeBreath() | |
end | |
function retakeBreath() | |
scopeSteady.Text = "Re-taking Breath" | |
scopeSteady.TextColor3 = C3(1, 0, 0) | |
local Increment = S.scopeSettings.steadyTime / S.scopeSettings.breathTime | |
repeat | |
RemoteService.send("Server","RegenStamina") | |
Stamina = RemoteService.fetch("Server","GetStamina","Reg") | |
if Stamina < maxStamina then | |
scopeSteady.Full.Bar.Size = UDIM2((1 - (Stamina/maxStamina)),0,1,0) | |
elseif Stamina >= maxStamina then | |
break | |
end | |
wait(0.25) | |
until | |
RemoteService.fetch("Server","GetStamina","Reg") >= RemoteService.fetch("Server","GetStamina","Max") | |
scopeSteady.Text = "Hold Left-Shift to Steady" | |
scopeSteady.TextColor3 = C3(1, 1, 0) | |
end | |
--------------------[ SPRINTING FUNCTIONS ]------------------------------------------- | |
function can(...) | |
local args = {...} | |
if args[1] == "Run" then | |
return ((Forward and (not Backward)) and | |
Walking and (Stamina > 0) and Running and | |
Selected and (args[2] and true or onGround) and | |
runReady and (S.canFireWhileRunning and true or (not Firing)) | |
) | |
end | |
end | |
function monitorStamina() | |
Running = true | |
if (not can("Run",false)) then | |
Running = false | |
return | |
end | |
if Aimed then unAimGun(true) end | |
if Stance == 1 or Stance == 2 then | |
changeStance("Stand") | |
end | |
if (not (Reloading and S.reloadSettings.Anim)) then | |
if S.canFireWhileRunning then | |
tween("Joint",ArmWelds.LWeld, armC0[1], S.unAimedC1.leftArm, Sine, 0.4) | |
tween("Joint",ArmWelds.RWeld, armC0[2], S.unAimedC1.rightArm, Sine, 0.4) | |
tween("Joint",Grips.Right, nil, S.unAimedC1.Grip, Sine, 0.4) | |
else | |
tween("Joint",ArmWelds.LWeld, armC0[1], S.runningC1.leftArm, Sine, 0.4) | |
tween("Joint",ArmWelds.RWeld, armC0[2], S.runningC1.rightArm, Sine, 0.4) | |
tween("Joint",Grips.Right, nil, S.runningC1.Grip, Sine, 0.4) | |
end | |
end | |
crossOffset = 50 | |
while runKeyPressed do | |
if can("Run",true) then | |
if onGround and WalkingTouch then | |
local newStamina = Stamina - 1 | |
Stamina = (newStamina < 0 and 0 or newStamina) | |
end | |
else | |
break | |
end | |
wait(0.25) | |
end | |
Running = false | |
if (not Aimed) and (not (Reloading and S.reloadSettings.Anim)) and (not S.canFireWhileRunning) then | |
crossOffset = 0 | |
tween("Joint",ArmWelds.LWeld, armC0[1], S.unAimedC1.leftArm, Sine, 0.4) | |
tween("Joint",ArmWelds.RWeld, armC0[2], S.unAimedC1.rightArm, Sine, 0.4) | |
tween("Joint",Grips.Right, nil, S.unAimedC1.Grip, Sine, 0.4) | |
end | |
end | |
Gun.Reload.Event:connect(Reload) | |
--------------------[ STANCE FUNCTIONS ]---------------------------------------------- | |
function changeStance(...) | |
local args = {...} | |
if args[1] == "Stand" then | |
local LHip = Torso["Left Hip"] | |
local RHip = Torso["Right Hip"] | |
LLegWeld.Part1 = nil | |
LHip.Part1 = LLeg | |
RLegWeld.Part1 = nil | |
RHip.Part1 = RLeg | |
Stance = 0 | |
spreadStance = "Stand" | |
baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion] | |
if S.stanceSettings.Anim and (not args[2]) then | |
runAsync(function() | |
local prevStanceSway = stanceSway | |
local X = 0 | |
local Increment = 1.5 / S.stanceSettings.Speed | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local newX = X + Increment | |
X = (newX > 90 and 90 or newX) | |
if Stance ~= 0 then break end | |
stanceSway = GunMath.numLerp(prevStanceSway, 1, Sine(X)) | |
if X == 90 then break end | |
end | |
end) | |
tween("Joint",ABWeld, CF.RAW(), nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",LLegWeld, legC0.Stand[1], nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",RLegWeld, legC0.Stand[2], nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",LHip, CF.RAW(-1, -1, 0) * CF.ANG(0, RAD(-90), 0), CF.RAW(-0.5, 1, 0) * CF.ANG(0, RAD(-90), 0), Sine, S.stanceSettings.Speed) | |
tween("Joint",RHip, 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), Sine, S.stanceSettings.Speed) | |
tween("Joint",Root, CF.ANG(RAD(-90), 0, RAD(180)), nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",headWeld, CF.RAW(0, 1.5, 0), nil, Sine, S.stanceSettings.Speed) | |
elseif args[2] or (not S.stanceSettings.Anim) then | |
ABWeld.C0 = CF.RAW() | |
LLegWeld.C0 = legC0.Stand[1] | |
RLegWeld.C0 = legC0.Stand[2] | |
LHip.C0, LHip.C1 = CF.RAW(-1, -1, 0) * CF.ANG(0, RAD(-90), 0), CF.RAW(-0.5, 1, 0) * CF.ANG(0, RAD(-90), 0) | |
RHip.C0, RHip.C1 = 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) | |
Root.C0 = CF.ANG(RAD(-90), 0, RAD(180)) | |
headWeld.C0 = CF.RAW(0, 1.5, 0) | |
end | |
elseif args[1] == "Crouch" then | |
local LHip = Torso["Left Hip"] | |
local RHip = Torso["Right Hip"] | |
LHip.Part1 = nil | |
LLegWeld.Part1 = LLeg | |
RHip.Part1 = nil | |
RLegWeld.Part1 = RLeg | |
Stance = 1 | |
spreadStance = "Crouch" | |
baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion] | |
if S.stanceSettings.Anim then | |
runAsync(function() | |
local prevStanceSway = stanceSway | |
local X = 0 | |
local Increment = 1.5 / S.stanceSettings.Speed | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local newX = X + Increment | |
X = (newX > 90 and 90 or newX) | |
if Stance ~= 1 then break end | |
stanceSway = GunMath.numLerp(prevStanceSway, 0.75, Sine(X)) | |
if X == 90 then break end | |
end | |
end) | |
tween("Joint",ABWeld, CF.RAW(0, 0, -0.05), nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",LLegWeld, legC0.Crouch[1], nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",RLegWeld, legC0.Crouch[2], nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",LHip, 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)), Sine, S.stanceSettings.Speed) | |
tween("Joint",RHip, 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), Sine, S.stanceSettings.Speed) | |
tween("Joint",Root, CF.RAW(0, -1, 0) * CF.ANG(RAD(-90), 0, RAD(180)), nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",headWeld, CF.RAW(0, 1.5, 0), nil, Sine, S.stanceSettings.Speed) | |
else | |
ABWeld.C0 = CF.RAW(0, 0, -0.0625) | |
LLegWeld.C0 = legC0.Crouch[1] | |
RLegWeld.C0 = legC0.Crouch[2] | |
LHip.C0, LHip.C1 = 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)) | |
RHip.C0, RHip.C1 = 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) | |
Root.C0 = CF.RAW(0, -1, 0) * CF.ANG(RAD(-90), 0, RAD(180)) | |
headWeld.C0 = CF.RAW(0, 1.5, 0) | |
end | |
elseif args[1] == "Prone" then | |
local LHip = Torso["Left Hip"] | |
local RHip = Torso["Right Hip"] | |
LHip.Part1 = nil | |
LLegWeld.Part1 = LLeg | |
RHip.Part1 = nil | |
RLegWeld.Part1 = RLeg | |
Stance = 2 | |
spreadStance = "Prone" | |
baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion] | |
if S.stanceSettings.Anim then | |
runAsync(function() | |
local prevStanceSway = stanceSway | |
local X = 0 | |
local Increment = 1.5 / S.stanceSettings.Speed | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local newX = X + Increment | |
X = (newX > 90 and 90 or newX) | |
if Stance ~= 2 then break end | |
stanceSway = GunMath.numLerp(prevStanceSway, 0.5, Sine(X)) | |
if X == 90 then break end | |
end | |
end) | |
tween("Joint",ABWeld, CF.RAW(0, 0, -0.1), nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",LLegWeld, legC0.Prone[1], nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",RLegWeld, legC0.Prone[2], nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",Root, CF.RAW(0, -2.5, 1) * CF.ANG(RAD(180), 0, RAD(180)), nil, Sine, S.stanceSettings.Speed) | |
tween("Joint",headWeld, CF.RAW(0, 1, 1) * CF.ANG(RAD(90), 0, 0), nil, Sine, S.stanceSettings.Speed) | |
else | |
ABWeld.C0 = CF.RAW(0, 0, -0.125) | |
LLegWeld.C0 = legC0.Prone[1] | |
RLegWeld.C0 = legC0.Prone[2] | |
Root.C0 = CF.RAW(0, -2.5, 1) * CF.ANG(RAD(180), 0, RAD(180)) | |
headWeld.C0 = CF.RAW(0, 1, 1) * CF.ANG(RAD(90), 0, 0) | |
end | |
elseif args[1] == "Dive" then | |
onGround = false | |
local diveDirection = (HRP.CFrame * CF.ANG(S.diveSettings.Angle, 0, 0)).lookVector * S.walkSpeeds.Sprinting * S.diveSettings.Force | |
spawn(function() | |
HRP.Velocity=HRP.CFrame.lookVector*60+V3.RAW(0,40,0) | |
wait(.1) | |
HRP.Velocity=HRP.CFrame.lookVector*70+V3.RAW(0,30,0) | |
wait(.4) | |
HRP.Velocity=HRP.CFrame.lookVector*30+V3.RAW(0,-10,0) | |
end) | |
runAsync(function() | |
while true do | |
local newRay = RAY.RAW(HRP.Position, V3.RAW(0, -3.1, 0)) | |
local H, _ = RAY.CAST(Services.WS,newRay, Ignore) | |
if H then | |
onGround = true | |
break | |
end | |
wait() | |
end | |
end) | |
changeStance("Prone") | |
wait(0.1) | |
end | |
end | |
--------------------[ MOUSE FUNCTIONS ]----------------------------------------------- | |
function onMB1Down() | |
MB1Down = true | |
firstShot = true | |
fire() | |
end | |
function onMB1Up() | |
MB1Down = false | |
lowerSpread() | |
end | |
function onMB2Down() | |
if S.aimSettings.holdToADS then | |
if (not AimingIn) and (not Aimed) then | |
AimingIn = true | |
aimGun() | |
AimingIn = false | |
end | |
else | |
if Aimed then | |
unAimGun() | |
else | |
aimGun() | |
end | |
end | |
end | |
function onMB2Up() | |
if S.aimSettings.holdToADS then | |
if (not AimingOut) and Aimed then | |
AimingOut = true | |
unAimGun() | |
AimingOut = false | |
end | |
end | |
end | |
--local newAimSensitivity = aimSensitivity + S.sensitivitySettings.Increment | |
--local newAimSensitivity = aimSensitivity - S.sensitivitySettings.Increment | |
--------------------[ INPUT FUNCTIONS ]-------------------------------------------- | |
for action, key2 in pairs(Libraries.Keybinds.GamepadButtons) do | |
print(action) | |
end | |
local function getGamepadAction(key) | |
for action, key2 in pairs(Libraries.Keybinds.GamepadButtons) do | |
if Interface.ModingSystem:IsPartOfMode(action) then | |
if key2 == key.Name then | |
return action | |
end | |
end | |
end | |
return nil | |
end | |
local function GamepadDown(input) | |
local ActionVars = { | |
Player = Player; | |
Reload = Reload; | |
Reloading = Reloading; | |
isCrawling = isCrawling; | |
setRunKeyPressed = function(bool) | |
runKeyPressed = bool | |
end; | |
CanRun = function() | |
return (not Idling) and Walking and (not Running) and (not Knifing) and (not (Aimed and S.guiScope and S.Keys.Sprint == S.Keys.scopeSteady)) | |
end; | |
monitorStamina = monitorStamina; | |
runReady = runReady; | |
holdToADS = S.aimSettings.holdToADS; | |
hasNotAimedYet = function() | |
return (not AimingIn) and (not Aimed) | |
end; | |
holdAndAim = function() | |
AimingIn = true | |
aimGun() | |
AimingIn = false | |
end; | |
rechargeTime = S.diveSettings.rechargeTime; | |
toggleAim = function() | |
if Aimed then | |
unAimGun() | |
else | |
aimGun() | |
end | |
end; | |
canChangeStance = S.canChangeStance; | |
Running = Running; | |
isProne = function() | |
return Stance == 2 | |
end; | |
canCrouch = S.stanceSettings.Stances.Crouch; | |
canGoProne = S.stanceSettings.Stances.Prone; | |
selectFire = S.selectFire; | |
canSelectFire = canSelectFire; | |
runAsync = runAsync; | |
toggleFireSelect = function(bool) | |
Interface.fireSelect.Visible = bool | |
end; | |
selectFireAnimSpeed = S.selectFireSettings.animSpeed; | |
waitRenderStepped = function() | |
shortWait(Services.RS.RenderStepped) | |
end; | |
getRawFireMode = function() | |
return rawFireMode | |
end; | |
updateGUI = updateGUI; | |
numModes = numModes; | |
fireModes = fireModes; | |
tutorialsEnabled = S.tutorialSettings.enabled; | |
ableToSelectFire = function() | |
return S.selectFireSettings.Animation and (not Aimed) and (not isRunning) and (not isCrawling) | |
end; | |
CF = CF.RAW; | |
CFANG = CF.ANG; | |
RAD = RAD; | |
Sine = Sine; | |
tween = tween; | |
LWeld = ArmWelds.LWeld; | |
RWeld = RWeld2; | |
LC0 = armC0[1]; | |
Linear = Linear; | |
unAimedLeftArmC1 = S.unAimedC1.leftArm; | |
PAIRS = PAIRS; | |
setupSteady = function() | |
steadyKeyPressed = true; | |
end; | |
throwTactical = function() | |
if Gun.TacticalGrenades.Value > 0 then | |
Gun.TacticalGrenades.Value = Gun.TacticalGrenades.Value - 1 | |
updateGUI("Grenades") | |
playAnimation("Nading",2) | |
end | |
end; | |
unAbleToSelectFire = function() | |
return Aimed or isRunning or isCrawling or Reloading | |
end; | |
hasSelectFireMedia = function() | |
return S.selectFireSettings.Animation or S.selectFireSettings.GUI | |
end; | |
hasSelectFireGUI = S.selectFireSettings.GUI; | |
selectFireMediaSpeed = S.selectFireSettings.animSpeed; | |
changeMode = function() | |
rawFireMode = rawFireMode + 1 | |
rawFireMode = ((rawFireMode - 1) % numModes) + 1 | |
modeGUI.Text = Modes[rawFireMode] | |
end; | |
throwLethal = function() | |
if Gun.LethalGrenades.Value > 0 then | |
Gun.LethalGrenades.Value = Gun.LethalGrenades.Value - 1 | |
updateGUI("Grenades") | |
playAnimation("Nading",1) | |
end | |
end; | |
dolphinDive = S.dolphinDive; | |
canDive = function() | |
return Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and (not Services.UIS:IsKeyDown("Space")) and runKeyPressed | |
end; | |
Humanoid = Humanoid; | |
changeStance = function(stance) | |
changeStance(stance) | |
end; | |
isCrouching = function() | |
return Stance == 1; | |
end; | |
isStanding = function() | |
return Stance == 0; | |
end; | |
readyToAim = function() | |
return Aimed and (not Aiming); | |
end; | |
holdBreath = function() | |
takingBreath = false; | |
end; | |
steadyCamera = steadyCamera; | |
} | |
local Key =(input.KeyCode) | |
if S.Debug then | |
mainGUI.Debug.Key.Text = Key.Name | |
end | |
if Libraries.XAdapt:IsGamepadButton(Key) then | |
Libraries.XAdapt.ButtonsDown = Libraries.XAdapt.ButtonsDown + 1 | |
end | |
local cond = nil | |
if (Interface.ModingSystem.Index == 1) then | |
cond = Key.Name ~= Libraries.Keybinds.GamepadButtons.scopeSteady | |
else | |
cond = true | |
end | |
print(getGamepadAction(Key)) | |
if cond then | |
if Libraries.DownActions[getGamepadAction(Key)] ~= nil then | |
Libraries.DownActions[getGamepadAction(Key)](ActionVars) | |
end | |
else | |
if Aimed and S.guiScope then | |
if Interface.ModingSystem:IsPartOfMode("scopeSteady") then | |
Libraries.DownActions["scopeSteady"](ActionVars) | |
end | |
else | |
if Interface.ModingSystem:IsPartOfMode("Sprint") then | |
Libraries.DownActions["Sprint"](ActionVars) | |
end | |
end | |
end | |
end | |
local function GamepadUp(input) | |
local ActionVars = { | |
holdToADS = S.aimSettings.holdToADS; | |
hasNotAimedOutYet = function() | |
return (not AimingOut) and Aimed | |
end; | |
unAim = function() | |
AimingOut = true | |
unAimGun() | |
AimingOut = false | |
end; | |
stopRunning = function() | |
runKeyPressed = false | |
Running = false | |
end; | |
unSteadyCamera = function() | |
steadyKeyPressed = false | |
end | |
} | |
local Key = input.KeyCode | |
if Libraries.XAdapt:IsGamepadButton(Key) then | |
Libraries.XAdapt.ButtonsDown = Libraries.XAdapt.ButtonsDown - 1 | |
end | |
if S.Debug then | |
mainGUI.Debug.Key.Text = Key.Name | |
end | |
if Key.Name ~= Libraries.Keybinds.GamepadButtons.scopeSteady then | |
if Interface.ModingSystem:IsPartOfMode(getGamepadAction(Key)) then | |
if Libraries.UpActions[getGamepadAction(Key)] ~= nil then | |
Libraries.UpActions[getGamepadAction(Key)](ActionVars) | |
elseif Key == Enum.KeyCode.Zero then | |
bindableService.send("ToggleInGameSens") | |
end | |
end | |
else | |
if Aimed and S.guiScope then | |
if Interface.ModingSystem:IsPartOfMode("scopeSteady") then | |
Libraries.UpActions["scopeSteady"](ActionVars) | |
end | |
else | |
if Interface.ModingSystem:IsPartOfMode("Sprint") then | |
Libraries.UpActions["Sprint"](ActionVars) | |
end | |
end | |
end | |
end | |
local function getKeyboardAction(key) | |
for action, key2 in pairs(Libraries.Keybinds.Keys) do | |
if key2 == key.Name then | |
return action | |
end | |
end | |
return nil | |
end | |
function keyDown(inputObj) | |
local ActionVars = { | |
Player = Player; | |
Reload = Reload; | |
Reloading = Reloading; | |
isCrawling = isCrawling; | |
setRunKeyPressed = function(bool) | |
runKeyPressed = bool | |
end; | |
CanRun = function() | |
return (not Idling) and Walking and (not Running) and (not Knifing) and (not (Aimed and S.guiScope and S.Keys.Sprint == S.Keys.scopeSteady)) | |
end; | |
monitorStamina = monitorStamina; | |
runReady = runReady; | |
holdToADS = S.aimSettings.holdToADS; | |
hasNotAimedYet = function() | |
return (not AimingIn) and (not Aimed) | |
end; | |
holdAndAim = function() | |
AimingIn = true | |
aimGun() | |
AimingIn = false | |
end; | |
rechargeTime = S.diveSettings.rechargeTime; | |
toggleAim = function() | |
if Aimed then | |
unAimGun() | |
else | |
aimGun() | |
end | |
end; | |
canChangeStance = S.canChangeStance; | |
Running = Running; | |
isProne = function() | |
return Stance == 2 | |
end; | |
canCrouch = S.stanceSettings.Stances.Crouch; | |
canGoProne = S.stanceSettings.Stances.Prone; | |
tutorialsEnabled = S.tutorialSettings.enabled; | |
selectFire = S.selectFire; | |
canSelectFire = canSelectFire; | |
runAsync = runAsync; | |
toggleFireSelect = function(bool) | |
Interface.fireSelect.Visible = bool | |
end; | |
selectFireAnimSpeed = S.selectFireSettings.animSpeed; | |
waitRenderStepped = function() | |
shortWait(Services.RS.RenderStepped) | |
end; | |
getRawFireMode = function() | |
return rawFireMode | |
end; | |
updateGUI = updateGUI; | |
numModes = numModes; | |
fireModes = fireModes; | |
ableToSelectFire = function() | |
return S.selectFireSettings.Animation and (not Aimed) and (not isRunning) and (not isCrawling) | |
end; | |
CF = CF.RAW; | |
CFANG = CF.ANG; | |
RAD = RAD; | |
Sine = Sine; | |
tween = tween; | |
LWeld = ArmWelds.LWeld; | |
RWeld = RWeld2; | |
LC0 = armC0[1]; | |
Linear = Linear; | |
unAimedLeftArmC1 = S.unAimedC1.leftArm; | |
PAIRS = PAIRS; | |
playAnimation = playAnimation; | |
setupSteady = function() | |
steadyKeyPressed = true; | |
end; | |
unAbleToSelectFire = function() | |
return Aimed or isRunning or isCrawling or Reloading | |
end; | |
hasSelectFireMedia = function() | |
return S.selectFireSettings.Animation or S.selectFireSettings.GUI | |
end; | |
Spot = function() | |
playAnimation("Spot") | |
end; | |
hasSelectFireGUI = S.selectFireSettings.GUI; | |
selectFireMediaSpeed = S.selectFireSettings.animSpeed; | |
changeMode = function() | |
rawFireMode = rawFireMode + 1 | |
rawFireMode = ((rawFireMode - 1) % numModes) + 1 | |
modeGUI.Text = Modes[rawFireMode] | |
end; | |
throwTactical = function() | |
if Gun.TacticalGrenades.Value > 0 then | |
Gun.TacticalGrenades.Value = Gun.TacticalGrenades.Value - 1 | |
updateGUI("Grenades") | |
playAnimation("Nading",2) | |
end | |
end; | |
throwLethal = function() | |
if Gun.LethalGrenades.Value > 0 then | |
Gun.LethalGrenades.Value = Gun.LethalGrenades.Value - 1 | |
updateGUI("Grenades") | |
playAnimation("Nading",1) | |
end | |
end; | |
dolphinDive = S.dolphinDive; | |
canDive = function() | |
return Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping and (not Services.UIS:IsKeyDown("Space")) and runKeyPressed | |
end; | |
Humanoid = Humanoid; | |
changeStance = function(stance) | |
changeStance(stance) | |
end; | |
isCrouching = function() | |
return Stance == 1; | |
end; | |
isStanding = function() | |
return Stance == 0; | |
end; | |
readyToAim = function() | |
return Aimed and (not Aiming); | |
end; | |
holdBreath = function() | |
takingBreath = false; | |
end; | |
steadyCamera = steadyCamera; | |
} | |
local Key =(inputObj.KeyCode) | |
if S.Debug then | |
mainGUI.Debug.Key.Text = Key.Name | |
end | |
local function getAction(key) | |
for action, key2 in pairs(Libraries.Keybinds.Keys) do | |
if key2 == key.Name then | |
return action | |
end | |
end | |
return nil | |
end | |
if Key.Name ~= Libraries.Keybinds.Keys.scopeSteady then | |
if Libraries.DownActions[getAction(Key)] ~= nil then | |
Libraries.DownActions[getAction(Key)](ActionVars) | |
end | |
else | |
if Aimed and S.guiScope then | |
Libraries.DownActions["scopeSteady"](ActionVars) | |
else | |
Libraries.DownActions["Sprint"](ActionVars) | |
end | |
end | |
for _, PTable in PAIRS(Libraries.Plugins.KeyDown) do | |
if Key ==(PTable.Key) then | |
spawn(function() | |
PTable.Plugin() | |
end) | |
end | |
end | |
end | |
function keyUp(inputObj) | |
local ActionVars = { | |
holdToADS = S.aimSettings.holdToADS; | |
hasNotAimedOutYet = function() | |
return (not AimingOut) and Aimed | |
end; | |
unAim = function() | |
AimingOut = true | |
unAimGun() | |
AimingOut = false | |
end; | |
stopRunning = function() | |
runKeyPressed = false | |
Running = false | |
end; | |
unSteadyCamera = function() | |
steadyKeyPressed = false | |
end | |
} | |
local Key = inputObj.KeyCode | |
if Key.Name ~= Libraries.Keybinds.Keys.scopeSteady then | |
if Libraries.UpActions[getKeyboardAction(Key)] ~= nil then | |
Libraries.UpActions[getKeyboardAction(Key)](ActionVars) | |
end | |
else | |
if Aimed and S.guiScope then | |
Libraries.UpActions["scopeSteady"](ActionVars) | |
else | |
Libraries.UpActions["Sprint"](ActionVars) | |
end | |
end | |
-- for _, PTable in PAIRS(Libraries.Plugins.KeyUp) do | |
-- if Key == (PTable.Key) then | |
-- runAsync(function() | |
-- PTable.Plugin() | |
-- end) | |
-- end | |
-- end | |
end | |
function TouchDown() | |
local ActionVars = { | |
Player = Player; | |
Reload = Reload; | |
Reloading = Reloading; | |
isCrawling = isCrawling; | |
setRunKeyPressed = function(bool) | |
runKeyPressed = bool | |
end; | |
CanRun = function() | |
return (not Idling) and Walking and (not Running) and (not Knifing) and (not (Aimed and S.guiScope and S.Keys.Sprint == S.Keys.scopeSteady)) | |
end; | |
monitorStamina = monitorStamina; | |
runReady = runReady; | |
holdToADS = S.aimSettings.holdToADS or (not Services.UIS.TouchEnabled); | |
hasNotAimedYet = function() | |
return (not AimingIn) and (not Aimed) | |
end; | |
holdAndAim = function() | |
AimingIn = true | |
aimGun() | |
AimingIn = false | |
end; | |
rechargeTime = S.diveSettings.rechargeTime; | |
toggleAim = function() | |
if Aimed then | |
unAimGun() | |
else | |
aimGun() | |
end | |
end; | |
canChangeStance = S.canChangeStance; | |
Running = Running; | |
isProne = function() | |
return Stance == 2 | |
end; | |
canCrouch = S.stanceSettings.Stances.Crouch; | |
canGoProne = S.stanceSettings.Stances.Prone; | |
tutorialsEnabled = S.tutorialSettings.enabled; | |
selectFire = S.selectFire; | |
canSelectFire = canSelectFire; | |
runAsync = runAsync; | |
toggleFireSelect = function(bool) | |
Interface.fireSelect.Visible = bool | |
end; | |
selectFireAnimSpeed = S.selectFireSettings.animSpeed; | |
waitRenderStepped = function() | |
shortWait(Services.RS.RenderStepped) | |
end; | |
getRawFireMode = function() | |
return rawFireMode | |
end; | |
updateGUI = updateGUI; | |
numModes = numModes; | |
fireModes = fireModes; | |
ableToSelectFire = function() | |
return S.selectFireSettings.Animation and (not Aimed) and (not isRunning) and (not isCrawling) | |
end; | |
CF = CF.RAW; | |
CFANG = CF.ANG; | |
RAD = RAD; | |
Sine = Sine; | |
tween = tween; | |
LWeld = ArmWelds.LWeld; | |
RWeld = RWeld2; | |
LC0 = armC0[1]; | |
Linear = Linear; | |
unAimedLeftArmC1 = S.unAimedC1.leftArm; | |
PAIRS = PAIRS; | |
playAnimation = playAnimation; | |
setupSteady = function() | |
steadyKeyPressed = true; | |
end; | |
unAbleToSelectFire = function() | |
return Aimed or isRunning or isCrawling or Reloading | |
end; | |
hasSelectFireMedia = function() | |
return S.selectFireSettings.Animation or S.selectFireSettings.GUI | |
end; | |
Spot = function() | |
playAnimation("Spot") | |
end; | |
hasSelectFireGUI = S.selectFireSettings.GUI; | |
selectFireMediaSpeed = S.selectFireSettings.animSpeed; | |
changeMode = function() | |
rawFireMode = rawFireMode + 1 | |
rawFireMode = ((rawFireMode - 1) % numModes) + 1 | |
modeGUI.Text = Modes[rawFireMode] | |
end; | |
throwTactical = function() | |
if Gun.TacticalGrenades.Value > 0 then | |
Gun.TacticalGrenades.Value = Gun.TacticalGrenades.Value - 1 | |
updateGUI("Grenades") | |
playAnimation("Nading",2) | |
end | |
end; | |
throwLethal = function() | |
if Gun.LethalGrenades.Value > 0 then | |
Gun.LethalGrenades.Value = Gun.LethalGrenades.Value - 1 | |
updateGUI("Grenades") | |
playAnimation("Nading",1) | |
end | |
end; | |
dolphinDive = S.dolphinDive; | |
canDive = function() | |
return Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping and (not Services.UIS:IsKeyDown("Space")) and runKeyPressed | |
end; | |
Humanoid = Humanoid; | |
changeStance = function(stance) | |
changeStance(stance) | |
end; | |
isCrouching = function() | |
return Stance == 1; | |
end; | |
isStanding = function() | |
return Stance == 0; | |
end; | |
readyToAim = function() | |
return Aimed and (not Aiming); | |
end; | |
holdBreath = function() | |
takingBreath = false; | |
end; | |
steadyCamera = steadyCamera; | |
} | |
for _, button in pairs(mainGUI.MobileCombat.Basic.Mode1:GetChildren()) do | |
if button:IsA("ImageButton") then | |
if Libraries.DownActions[button.Name] and button.Name ~= "ADS" then | |
button.MouseButton1Down:connect(function() | |
Libraries.DownActions[button.Name](ActionVars) | |
end) | |
else | |
if button.Name == "ADS" then | |
button.MouseButton1Up:connect(function() | |
if Aimed then | |
unAimGun() | |
else | |
aimGun() | |
end | |
end) | |
end | |
end | |
end | |
end | |
for _, button in pairs(mainGUI.MobileCombat.Basic.Mode2:GetChildren()) do | |
if button:IsA("ImageButton") then | |
if Libraries.DownActions[button.Name] and button.Name ~= "ADS" then | |
button.MouseButton1Down:connect(function() | |
Libraries.DownActions[button.Name](ActionVars) | |
end) | |
end | |
end | |
end | |
end | |
function TouchUp() | |
local ActionVars = { | |
holdToADS = S.aimSettings.holdToADS or (not Services.UIS.TouchEnabled); | |
hasNotAimedOutYet = function() | |
return (not AimingOut) and Aimed | |
end; | |
unAim = function() | |
AimingOut = true | |
unAimGun() | |
AimingOut = false | |
end; | |
stopRunning = function() | |
runKeyPressed = false | |
Running = false | |
end; | |
unSteadyCamera = function() | |
steadyKeyPressed = false | |
end | |
} | |
for _, button in pairs(mainGUI.MobileCombat.Basic.Mode1:GetChildren()) do | |
if button:IsA("ImageButton") then | |
if Libraries.UpActions[button.Name] and button.Name ~= "ADS" then | |
button.MouseButton1Up:connect(function() | |
Libraries.UpActions[button.Name](ActionVars) | |
end) | |
end | |
end | |
end | |
for _, button in pairs(mainGUI.MobileCombat.Basic.Mode2:GetChildren()) do | |
if button:IsA("ImageButton") then | |
if Libraries.UpActions[button.Name] and button.Name ~= "ADS" then | |
button.MouseButton1Up:connect(function() | |
Libraries.UpActions[button.Name](ActionVars) | |
end) | |
end | |
end | |
end | |
end | |
--------------------[ END FUNCTIONS ]------------------------------------------------- | |
-------------------------------------------------------------------------------------- | |
--------------------[ PRE-CONNECTIONS ]----------------------------------------------- | |
-------------------------------------------------------------------------------------- | |
--bindableService.fetch("IsUsingThumbstick") | |
local function updateAnimVars() | |
local direction = V3.RAW(0,0,0) | |
if Services.UIS.TouchEnabled then | |
direction = -bindableService.fetch("GetThumbstickDirection",1) | |
end | |
Forward = (Services.UIS:IsKeyDown("W") or Services.UIS:IsKeyDown("Up") or WalkingGamepad or direction.Z < 0) | |
Backward = (Services.UIS:IsKeyDown("S") or Services.UIS:IsKeyDown("Down") or direction.Z > 0) | |
local Right = Services.UIS:IsKeyDown("D") or direction.X > 0 | |
local Left = Services.UIS:IsKeyDown("A") or direction.X < 0 | |
local walkingForward = (Forward and (not Backward)) | |
local walkingBackward = ((not Forward) and Backward) | |
local walkingRight = (Right and (not Left)) | |
local walkingLeft = ((not Right) and Left) | |
if (Forward or Backward or Right or Left) then | |
Walking, Idling = true, false | |
if (not Running) and (not Aimed) then | |
spreadMotion = "Moving" | |
baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion] | |
end | |
elseif (not (Forward and Backward and Right and Left)) then | |
Walking, Idling = false, true | |
if (not Aimed) then | |
spreadMotion = "Idling" | |
baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion] | |
end | |
end | |
local newArmTilt = ( | |
((walkingForward or walkingBackward) and walkingRight) and 2.5 or | |
((walkingForward or walkingBackward) and walkingLeft) and -2.5 or | |
((not (walkingForward and walkingBackward)) and walkingRight) and 5 or | |
((not (walkingForward and walkingBackward)) and walkingLeft) and -5 or 0 | |
) | |
local newMoveAng = ( | |
(walkingForward and (not (walkingRight or walkingLeft))) and 0 or | |
(walkingForward and walkingRight) and RAD(-45) or | |
((not (walkingForward or walkingBackward)) and walkingRight) and RAD(-90) or | |
(walkingBackward and walkingRight) and RAD(-135) or | |
(walkingBackward and (not (walkingRight or walkingLeft))) and (moveAng < 0 and RAD(-180) or RAD(180)) or | |
(walkingBackward and walkingLeft) and RAD(135) or | |
((not (walkingForward or walkingBackward)) and walkingLeft) and RAD(90) or | |
(walkingForward and walkingLeft) and RAD(45) or 0 | |
) | |
local newAnimCode = RANDOM(-1e9, 1e9) | |
animCode = newAnimCode | |
local startTilt = armTilt | |
local startAng = (ABS(moveAng) == RAD(180)) and (newMoveAng > 0 and RAD(180) or RAD(-180)) or moveAng | |
local Increment = (startTilt == newArmTilt and 1.5 / 0.7 or 1.5 / (0.35 * ABS(startTilt - newArmTilt) / 5)) | |
local X = 0 | |
local armLerp, angLerp | |
while true do | |
shortWait(Services.RS.Heartbeat) | |
local newX = X + Increment | |
X = (newX > 90 and 90 or newX) | |
if animCode ~= newAnimCode then break end | |
armLerp = GunMath.numLerp(startTilt, newArmTilt, Sine(X)) | |
armTilt = armLerp | |
angLerp = GunMath.numLerp(startAng, newMoveAng, Sine(X)) | |
moveAng = angLerp | |
if X == 90 then break end | |
end | |
end | |
Services.UIS.InputBegan:connect(updateAnimVars) | |
Services.UIS.InputEnded:connect(updateAnimVars) | |
Services.UIS.InputChanged:connect(updateAnimVars) | |
updateAnimVars() | |
function setUpTouchControls() | |
local function positionIntersectsGuiObject(position, guiObject) | |
if position.X < guiObject.AbsolutePosition.X + guiObject.AbsoluteSize.X | |
and position.X > guiObject.AbsolutePosition.X | |
and position.Y < guiObject.AbsolutePosition.Y + guiObject.AbsoluteSize.Y | |
and position.Y > guiObject.AbsolutePosition.Y then | |
return true | |
end | |
return false | |
end | |
if Services.UIS.TouchEnabled then | |
local function pinchInGui(positions, guiObject) | |
for _, pos in pairs(positions) do | |
if typeof(pos) == "Vector2" then | |
if not positionIntersectsGuiObject(pos,guiObject) then | |
return false | |
end | |
end | |
end | |
return true | |
end | |
INSERT(Connections,Services.RS.RenderStepped:connect(function() | |
if runKeyPressed then | |
monitorStamina() | |
end | |
end)) | |
INSERT(Connections,Services.UIS.TouchSwipe:connect(function(swipeDir,touches,processed) | |
if touches < 2 then | |
if swipeDir == Enum.SwipeDirection.Down then | |
elseif swipeDir == Enum.SwipeDirection.Right then | |
-- runKeyPressed = not runKeyPressed | |
-- repeat Services.RS.Heartbeat:wait() until Player.Stats.Stamina.Value <= 0 | |
-- runKeyPressed = not runKeyPressed | |
end | |
elseif touches >= 2 and swipeDir == Enum.SwipeDirection.Down then | |
if Running then | |
if S.DolphinDive then | |
wait() | |
if Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and runReady then | |
local tempConnection = Humanoid.Changed:connect(function() | |
Humanoid.Jump = false | |
end) | |
runReady = false | |
changeStance("Dive") | |
Running = false | |
wait(S.diveSettings.rechargeTime) | |
tempConnection:disconnect() | |
runReady = true | |
end | |
end | |
end | |
end | |
end)) | |
end | |
end | |
-------------------------------------------------------------------------------------- | |
--------------------[ TOOL SELECTION AND DESELECTION ]-------------------------------- | |
-------------------------------------------------------------------------------------- | |
local function enableModing() | |
end | |
local function calculateMovement(inputObj) | |
if inputObj.UserInputType == InputTypes.MouseMovement then | |
local rawCamAng = camAng - (VEC2(RAD(inputObj.Delta.x), RAD(inputObj.Delta.y)) * Sensitivity.mouse * 0.25) | |
camAng = VEC2(rawCamAng.x, (rawCamAng.y > RAD(80) and RAD(80) or rawCamAng.y < RAD(-80) and RAD(-80) or rawCamAng.y)) | |
if (inputObj.Delta).magnitude > 0 then | |
desiredXOffset = MIN(MAX(inputObj.Delta.x, -S.momentumSettings.maxInput), S.momentumSettings.maxInput) | |
desiredYOffset = MIN(MAX(inputObj.Delta.y, -S.momentumSettings.maxInput), S.momentumSettings.maxInput) | |
else | |
desiredXOffset = 0 | |
desiredYOffset = 0 | |
end | |
elseif inputObj.UserInputType == Enum.UserInputType.Gamepad1 then | |
if inputObj.KeyCode == Enum.KeyCode.Thumbstick2 then | |
while VEC2(inputObj.Position.X,-inputObj.Position.Y).magnitude > 0.2 do | |
local rawCamAng = camAng - (VEC2(RAD(inputObj.Position.X)*2, RAD(-inputObj.Position.Y)*2) * Sensitivity.mouse* 0.5) | |
camAng = VEC2(rawCamAng.x, (rawCamAng.y > RAD(80) and RAD(80) or rawCamAng.y < RAD(-80) and RAD(-80) or rawCamAng.y)) | |
if (inputObj.Position).magnitude ~= 0 then | |
desiredXOffset = MIN(MAX(inputObj.Position.X, -S.momentumSettings.maxInput), S.momentumSettings.maxInput) | |
desiredYOffset = MIN(MAX(-inputObj.Position.Y, -S.momentumSettings.maxInput), S.momentumSettings.maxInput) | |
else | |
desiredXOffset = 0 | |
desiredYOffset = 0 | |
end | |
shortWait(Services.RS.Heartbeat) | |
end | |
elseif inputObj.KeyCode == Enum.KeyCode.Thumbstick1 then | |
WalkingGamepad = (VEC2(inputObj.Position.X,-inputObj.Position.Y).magnitude > 0.2) | |
updateAnimVars() | |
end | |
end | |
end | |
Libraries.Network.listen("Client","Send","markHit_"..Player.UserId,function() | |
markHit() | |
end) | |
Libraries.Network.listen("Client","Fetch","getAnimCF_"..Player.UserId,function() | |
return getAnimCF("General") | |
end) | |
Libraries.Network.listen("Client","Fetch","penetrateWall_"..Player.UserId,function(Wall, hitPos, Direction, Normal, Ignore, totalPDist, totalBDist, lastDamagedHumanoid) | |
return penetrateWall(Wall, hitPos, Direction, Normal, Ignore, totalPDist, totalBDist, lastDamagedHumanoid) | |
end) | |
Libraries.Network.startClient(); | |
local function onEquipped() | |
wait() | |
if Humanoid.Health ~= 0 and (not Selected) and Gun.Parent == Char then | |
Selected = true | |
breakReload = false | |
equipAnimPlaying = true | |
local SlidePart = Gun:WaitForChild("SlidePart",200) | |
for _, main in pairs(Gun:GetChildren()) do | |
if main.Name == "Main" then | |
if main:IsA("BasePart") then | |
if main:FindFirstChild("BarrelIndex") then | |
if tonumber(main.BarrelIndex.Value) then | |
Main[main.BarrelIndex.Value] = main | |
end | |
end | |
end | |
end | |
end | |
--------------------[ FAILSAFE RESETING ]------------------------------------- | |
for _, GM in PAIRS(OBJ.GetKids(ignoreModel)) do | |
if GM.Name == "gunIgnore_"..Player.Name then | |
OBJ.Destroy(GM) | |
end | |
end | |
for _, c in PAIRS(Connections) do | |
c:disconnect() | |
end | |
Connections = {} | |
--------------------[ REMOTE GUN SETUP ]-------------------------------------- | |
Libraries.Network.enable(); | |
local isTouchEnabled = Services.UIS.TouchEnabled | |
local RS = Services.RS | |
local camMode = RemoteService.fetch("Server","GetWeaponCMode","Gun") | |
local start = tick() | |
local fakeLWeld,fakeRWeld,gIgnoreHum | |
local Vars = { | |
Humanoid = Humanoid; | |
Shoulders = Shoulders; | |
Torso = Torso; | |
Head = Head; | |
LArm = LArm; | |
RArm = RArm; | |
armC0 = armC0; | |
} | |
gunIgnore, playerFolder, headWeld, headWeld2, ArmBase, animWeld, ABWeld, ArmWelds.LWeld, ArmWelds.RWeld, LWeld2, RWeld2, LLegWeld, RLegWeld, Grips.Right, Grips.Left = Libraries.Network.fetch("Server","gunSetup_"..Player.UserId,Vars) | |
local Vars2 = { | |
Humanoid = Humanoid; | |
LArm = LArm; | |
RArm = RArm; | |
playerFolder = playerFolder; | |
} | |
armModel = Libraries.Network.fetch("Server","MakeArms",Vars2) | |
fakeLArm = armModel["Left Arm"] | |
fakeRArm = armModel["Right Arm"] | |
fakeLWeld = armModel["Left Arm"]:FindFirstChild("FLWeld") | |
fakeRWeld = armModel["Right Arm"]:FindFirstChild("FRWeld") | |
gIgnoreHum = armModel.Humanoid | |
Player.CameraMode = "LockFirstPerson" | |
Interface.Cam.CameraType = "Scriptable" | |
Interface.Cam.FieldOfView = 80 | |
Services.UIS.MouseBehavior = "LockCenter" | |
Services.UIS.MouseIconEnabled = (not camMode:find("FirstPerson")) | |
if Services.UIS.MouseIconEnabled then | |
Interface.crossHair.Visible = false | |
Interface.M2.Icon = "rbxassetid://1415957732" | |
end | |
local initialX, initialY = GunMath.getYawPitch(Head.CFrame) | |
if CameraService.Angles then | |
camAng = CameraService.Angles | |
else | |
camAng = -VEC2(initialX, initialY) | |
end | |
mainGUI.Visible = true | |
setUpGUI() | |
updateGUI("Cartridge") | |
local currentMode = Modes[rawFireMode] | |
if camMode == "FirstPersonFireArm" then | |
changePlayerTrans(Char, 1) | |
end | |
--------------------[ RUNNING PLUGINS ]--------------------------------------- | |
for _, Plugin in PAIRS(Libraries.Plugins.OnEquipped) do | |
runAsync(function() | |
Plugin() | |
end) | |
end | |
--------------------[ CONNECTIONS ]------------------------------------------- | |
INSERT(Connections, Humanoid.Died:connect(function() | |
onUnequipped(true) | |
end)) | |
INSERT(Connections, Humanoid.Jumping:connect(function() | |
if Stance ~= 0 then | |
changeStance("Stand") | |
end | |
if not Reloading and not Aimed then | |
local r1=RAY.RAW(HRP.CFrame.p+V3.RAW(0,-1.5,0),HRP.CFrame.lookVector*25+V3.RAW(0,-2,0)) | |
local h1,e1= RAY.CAST(workspace,r1,Ignore) | |
local r2=RAY.RAW(HRP.CFrame.p-V3.RAW(0,-.8,0),(HRP.CFrame.lookVector)*25-V3.RAW(0,-.8,0)) | |
local h2,e2=RAY.CAST(workspace,r2,Ignore) | |
local r3=RAY.RAW(HRP.CFrame.p-V3.RAW(0,1.2,0),(HRP.CFrame.lookVector)*25-V3.RAW(0,-1.2,0)) | |
local h3,e3=RAY.CAST(workspace,r3,Ignore) | |
if h3 and (e3-e2).Magnitude<20 and (e3-e1).Magnitude>0.25 and (e3-HRP.Position).Magnitude<Humanoid.WalkSpeed/2 then | |
playAnimation("Parkour",h3) | |
end | |
end | |
end)) | |
INSERT(Connections, Humanoid.StateChanged:connect(onHumanoidStateChanged)) | |
if isTouchEnabled then | |
INSERT(Connections,mainGUI.MobileCombat.Basic.Mode1.Fire.MouseButton1Down:connect(function() | |
if not MB1Down then | |
onMB1Down() | |
end | |
end)) | |
INSERT(Connections,mainGUI.MobileCombat.Basic.Mode1.Fire.MouseButton1Up:connect(function() | |
if MB1Down then | |
onMB1Up() | |
end | |
end)) | |
INSERT(Connections,mainGUI.MobileCombat.ModeActions.Next.MouseButton1Click:connect(function() | |
mainGUI.MobileCombat.Basic.ModeController:Next() | |
end)) | |
INSERT(Connections,mainGUI.MobileCombat.ModeActions.Prev.MouseButton1Click:connect(function() | |
mainGUI.MobileCombat.Basic.ModeController:Previous() | |
end)) | |
TouchDown() | |
TouchUp() | |
INSERT(Connections,mainGUI.TouchPad.InputChanged:connect(function(inputObject,gp) | |
local delta = inputObject.Delta | |
local rawCamAng = camAng - ((VEC2(RAD(delta.x),RAD(delta.y)) * Sensitivity.aim)) | |
camAng = VEC2(rawCamAng.x, (rawCamAng.y > RAD(80) and RAD(80) or rawCamAng.y < RAD(-80) and RAD(-80) or rawCamAng.y)) | |
desiredXOffset = math.min(math.max(inputObject.Position.X/32, -S.momentumSettings.maxInput), S.momentumSettings.maxInput) | |
desiredYOffset = math.min(math.max(inputObject.Position.Y/64, -S.momentumSettings.maxInput), S.momentumSettings.maxInput) | |
end)) | |
end | |
INSERT(Connections,Services.UIS.InputBegan:connect(function(input,gp) | |
if not CameraService.CutsceneSysBusy then | |
if not gp then | |
if input.UserInputType == Enum.UserInputType.Keyboard then | |
keyDown(input) | |
elseif input.UserInputType.Name:find("Gamepad") then | |
if input.KeyCode == Enum.KeyCode.ButtonR2 then | |
onMB1Down() | |
elseif input.KeyCode == Enum.KeyCode.DPadUp then | |
Interface.ModingSystem:NextMode() | |
elseif input.KeyCode == Enum.KeyCode.DPadDown then | |
Interface.ModingSystem:PrevMode() | |
else | |
GamepadDown(input) | |
end | |
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then | |
onMB1Down() | |
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then | |
onMB2Down() | |
end | |
end | |
end | |
end)) | |
if S.singleUse then | |
Libraries.Network.listen("Client","Fetch","Dispose",function() | |
onUnequipped(false) | |
return true | |
end) | |
end | |
INSERT(Connections,Services.UIS.InputEnded:connect(function(input,gp) | |
if not CameraService.CutsceneSysBusy then | |
if not gp then | |
if input.UserInputType == Enum.UserInputType.Keyboard then | |
keyUp(input) | |
elseif input.UserInputType.Name:find("Gamepad") then | |
if input.KeyCode == Enum.KeyCode.ButtonR2 then | |
onMB1Up() | |
else | |
GamepadUp(input) | |
end | |
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then | |
onMB1Up() | |
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then | |
onMB2Up() | |
end | |
end | |
end | |
end)) | |
-- INSERT(Connections, Humanoid.Climbing:connect(function(speed) | |
-- if not Climbing then | |
-- Climbing = true | |
-- Climb() | |
-- Climbing = false | |
-- end | |
-- end)) | |
INSERT(Connections, Services.UIS.InputChanged:connect(function(inputObj,processed) | |
if not CameraService.CutsceneSysBusy then | |
calculateMovement(inputObj) | |
end | |
end)) | |
if isTouchEnabled then | |
setUpTouchControls() | |
mainGUI.MobileCombat.Visible = true | |
end | |
Interface.HUD.Visible = (not isTouchEnabled) | |
RS:BindToRenderStep("UpdateAnimWeld",Enum.RenderPriority.Character.Value,function(dt) | |
local animC0, animC1 = getAnimCF("General") | |
animWeld.C0 = animC0 | |
animWeld.C1 = animC1 | |
Libraries.Network.send("Server","changeAnimC1_"..Player.UserId,animWeld,animWeld.C0,animWeld.C1) | |
end) | |
RS:BindToRenderStep("UpdateCamAng",Enum.RenderPriority.Camera.Value,function(dt) | |
CameraService.CurrentModeVars.camAng = camAng | |
Services.UIS.MouseBehavior = Enum.MouseBehavior.LockCenter | |
if camMode == "FirstPersonFireArm" then | |
changePlayerTrans(Char, 1) | |
end | |
end) | |
BoltWelds = Libraries.Network.fetch("Server","GetBoltWelds") | |
for key,boltWeld in pairs(BoltWelds) do | |
if key then | |
boltAnim[key] = { | |
Kick = V3.RAW(); | |
Rot = V3.RAW(); | |
Code = 0; | |
}; | |
end | |
end | |
RS:BindToRenderStep("UpdateBoltWeld",Enum.RenderPriority.Character.Value,function(dt) | |
pcall(function() | |
for key, weld in pairs(BoltWelds) do | |
weld.C1 = getAnimCF("Bolt",key) | |
Libraries.Network.send("Server","changeBoltC1_"..Player.UserId,weld,weld.C1) | |
end | |
end) | |
end) | |
CameraService:setCamMode(camMode,camAng,GunMath.getTotalCamOffset,Head,crawlCamRot) | |
--------------------[ ANIMATE GUN ]------------------------------------------- | |
runAsync(function() | |
tween("Joint",ArmWelds.LWeld, nil, S.unAimedC1.leftArm, Sine, S.equipSettings.Time) | |
tween("Joint",ArmWelds.RWeld, nil, S.unAimedC1.rightArm, Sine, S.equipSettings.Time) | |
tween("Joint",Grips.Right, nil, S.unAimedC1.Grip, Sine, S.equipSettings.Time) | |
end) | |
runAsync(function() | |
local T = TICK() | |
while true do | |
if TICK() - T > S.equipSettings.Time then break end | |
if (not Selected) then break end | |
RS.Heartbeat:wait() | |
end | |
equipAnimPlaying = false | |
end) | |
Animate() | |
end | |
end | |
function onUnequipped(deleteTool) | |
if Selected then | |
Selected = false | |
breakReload = true | |
--------------------[ RUNNING PLUGINS ]--------------------------------------- | |
for _, Plugin in PAIRS(Libraries.Plugins.OnUnEquipped) do | |
runAsync(function() | |
Plugin() | |
end) | |
end | |
Interface.HUD.Visible = false | |
--------------------[ MODIFYING THE PLAYER ]---------------------------------- | |
CameraService.CurrentModeVars:Stop() | |
Services.UIS.MouseIconEnabled = true | |
mainGUI.Visible = false | |
if armModel then | |
Libraries.Network.send("Server","RemoveArmModel",armModel) | |
end | |
LLegWeld:Destroy() | |
RLegWeld:Destroy() | |
Libraries.Network.send("Server","ResetShoulders_"..Player.UserId,Shoulders,LArm,RArm) | |
Libraries.Network.send("Server","DestroyHeadWeld_"..Player.UserId,headWeld) | |
Humanoid.WalkSpeed = 16 | |
Humanoid.AutoRotate = true | |
Interface.Cam.CameraType = Enum.CameraType.Custom | |
--------------------[ RESETING THE TOOL ]------------------------------------- | |
MB1Down = false | |
Aimed = false | |
camOffsets = { | |
guiScope = Libraries.PrimitiveAnim.new(V3.RAW()); | |
Reload = Libraries.PrimitiveAnim.new(V3.RAW(),nil); | |
Recoil = Libraries.PrimitiveAnim.new(V3.RAW(),nil); | |
} | |
recoilAnim = Libraries.PrimitiveAnim.new(V3.RAW(),nil,V3.RAW()); | |
--Setting the aim variables to unaimed | |
spreadZoom = "unAimed" | |
scopeMain.Visible = false | |
scopeSteady.Visible = false | |
aimAlpha = 0 | |
aimHeadOffset = 0 | |
jumpAnimMultiplier = 1 | |
translationDivisor = 7 | |
rotationMultiplier = S.momentumSettings.Amplitude.unAimed | |
armTiltMultiplier = 1 | |
Interface.Scope.BackgroundTransparency = 1 | |
if S.guiScope then | |
runAsync(function() | |
for _, Obj in PAIRS(OBJ.GetKids(Gun)) do | |
if Obj:IsA("BasePart") then | |
Obj.LocalTransparencyModifier = 0 | |
end | |
end | |
end) | |
end | |
onGround = true | |
for _,c in PAIRS(Connections) do | |
c:disconnect() | |
end | |
Services.RS:UnbindFromRenderStep("UpdateAnimWeld") | |
Services.RS:UnbindFromRenderStep("UpdateBoltWeld") | |
Services.RS:UnbindFromRenderStep("UpdateCamAng") | |
changePlayerTrans(Char, 0) | |
Libraries.Network.send("Server","ShowRegularArms",LArm,RArm) | |
Connections = {} | |
Libraries.Network.fetch("Server","destroyGunIgnore_"..Player.UserId,gunIgnore) | |
if deleteTool then | |
Interface.Cam:ClearAllChildren() | |
OBJ.Destroy(Gun) | |
end | |
-- Services.CAS:UnbindAction("Walk") | |
wait() --This is here in case you dolphin dived and deselected the tool instantly | |
if S.stanceSettings.standOnDeselect and Stance ~= 0 then | |
crawlCamRot = 0 | |
isCrawling = false | |
stanceSway = 1 | |
spreadStance = "Stand" | |
changeStance("Stand",true) | |
end | |
baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion] | |
Libraries.Network.reset() | |
Interface.Cam.FieldOfView = 70 | |
Interface.Cam.CameraType = Enum.CameraType.Custom | |
Interface.Cam:ClearAllChildren() | |
Player.CameraMode = Enum.CameraMode.Classic | |
Humanoid.WalkSpeed = 16 | |
Humanoid.AutoRotate = true | |
end | |
end | |
Gun.Equipped:connect(onEquipped) | |
Gun.Unequipped:connect(function() onUnequipped(false) end) | |
-------------------------------------------------------------------------------------- | |
--------------------[ END PROGRAM ]--------------------------------------------------- | |
-------------------------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local DamageTag = require(game.ReplicatedStorage.DamageTag) | |
game.CollectionService:AddTag(script.Parent,game.HttpService:GenerateGUID(false)) | |
game.CollectionService:AddTag(script.Parent,"Weapon") | |
local Plyr = script:WaitForChild("Plyr") | |
Plyr.Value = game.Players:GetPlayerFromCharacter(script.Parent.Parent) or script.Parent.Parent.Parent | |
local Character = Plyr.Value.Character | |
local Network = require(game.ReplicatedStorage.RemoteService.Plugin_Gun)(Plyr.Value,script.Parent.Name,true,script.Parent) | |
local RemoteService = require(game.ReplicatedStorage.RemoteService) | |
local BindableService = require(game.ReplicatedStorage.BindingService)() | |
Network.listen("Server","Send","SetCam_"..Plyr.Value.UserId,function(player, Cam) | |
script:WaitForChild("Cam").Value = Cam | |
end) | |
local RS = game:GetService("RunService") | |
local BC = BrickColor.new | |
local FFC = game.FindFirstChild | |
local PL = game.Players | |
local Cam = script.Cam.Value | |
local Char = Plyr.Value.Character | |
local TOS = CFrame.new().toObjectSpace | |
local Gun = script.Parent | |
local Handle = Gun:WaitForChild("Handle",200) | |
local SlidePart = Gun:FindFirstChild("SlidePart") | |
local CollectionService = game:GetService("CollectionService") | |
local RAY = Ray.new | |
local RANDOM = math.random | |
local FE = workspace.FilteringEnabled | |
local V3 = Vector3.new | |
local CF, CFANG, CFTOS = CFrame.new, CFrame.Angles, CFrame.new().toObjectSpace | |
local PAIRS = pairs | |
local S = require(Gun.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 MIN,MAX = math.min,math.max | |
local RAD,CEIL,FLOOR = math.rad,math.ceil,math.floor | |
local NSEQ,CSEQ,OBJ = NumberSequence.new,ColorSequence.new,Instance.new | |
local UD2 = UDim2.new | |
local NRANGE = NumberRange.new | |
local RAY = Ray.new | |
local JointC0,JointC1 | |
local WS = workspace | |
local gunIgnore | |
local animWeld | |
local AfterEffects = require(game.ReplicatedStorage.GunLibraries.AfterEffect) | |
local Cartridges = require(game.ReplicatedStorage.Settings.Cartridges) | |
local Grip | |
local Grip2 | |
local DS = game:GetService("Debris") | |
function ArcTan(x, y) | |
local r = math.atan(y / x) | |
if x < 0 then | |
r = r + math.pi | |
end | |
return r | |
end | |
local RPGM = require(game.ReplicatedStorage.RPGMathProvider) | |
local numLerp = function(A, B, Alpha) | |
return A + (B - A) * Alpha | |
end | |
local runAsync = function(threadFunc) | |
coroutine.resume(coroutine.create(threadFunc)) | |
end | |
local raycast = WS.FindPartOnRayWithIgnoreList | |
local function isEnemy(Human) | |
local Plyr2 = game.Players:GetPlayerFromCharacter(Human.Parent) | |
if (not Plyr2) then if S.CanDamageNPCs then | |
if Human.Parent:FindFirstChild("BOT") then | |
return (require(Human.Parent.BOT).Team ~= Plyr.Value.Team) | |
end | |
end | |
end | |
return S.AllowFriendlyFire or (Plyr2 ~= nil and (Plyr2.Team~= Plyr.Value.Team or Plyr2.Neutral)) | |
end | |
local Connections = {} | |
local function Weld(p0,p1,c0,c1,par) | |
local w = OBJ("Weld") | |
w.Part0 = p0 | |
w.Part1 = p1 | |
w.C0 = c0 or CF() | |
w.C1 = c1 or CF() | |
w.Parent = p0 or par | |
return w | |
end | |
function CreatePart() | |
local p = Instance.new("Part") | |
p.CanCollide = false | |
p.Transparency = 1 | |
p.TopSurface = "Unjoinable" | |
p.BottomSurface = "Unjoinable" | |
p.FormFactor = "Custom" | |
p.Size = Vector3.new(0.2, 0.2, 0.2) | |
return p | |
end | |
local function Motor(p0,p1,c0,c1,des,vel,par) | |
local w = OBJ("Motor6D") | |
w.Part0 = p0 | |
w.Part1 = p1 | |
w.C0 = c0 or CF() | |
w.C1 = c1 or CF() | |
w.MaxVelocity = tonumber(vel) or .05 | |
w.DesiredAngle = tonumber(des) or 0 | |
w.Parent = p0 or par | |
return w | |
end | |
Network.listen("Server","Send","SetPlayer_"..Plyr.Value.UserId,function(player, Cam) | |
if not script.Plyr.Value then | |
script.Plyr.Value = player | |
end | |
end) | |
local function DisplayDamage(damage,humanoid) | |
local part2 = OBJ("TextLabel") | |
part2.Font = "Highway" | |
part2.FontSize = "Size24" | |
part2.TextStrokeTransparency = 0 | |
part2.Size = UD2(1,0,1,0) | |
part2.Position = UD2(0,0,0,0) | |
part2.BackgroundTransparency = 1 | |
part2.Parent = humanoid.Parent.Head.DamageGUI | |
runAsync(function() | |
part2:TweenPosition(UDim2.new(0,0,0,-98)) | |
wait(1) | |
for i = 1, 20 do | |
part2.TextTransparency = part2.TextTransparency + 0.05 | |
wait(0.025) | |
end | |
end) | |
if (damage == 0) then | |
part2.TextColor3 = Color3.new(0,0.5,1) | |
part2.Text = "Miss!" | |
else | |
part2.TextColor3 = Color3.new(1,1,1) | |
part2.Text = damage | |
end | |
end | |
local function tagHumanoid(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)[2],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)[2],game.CollectionService:GetTags(player)[1],headShot) | |
end | |
tag:MarkEnemy(humanoid) | |
end | |
local inList = function(Element, List) | |
for _, v in PAIRS(List) do | |
if v == Element then | |
return true | |
end | |
end | |
return false | |
end | |
local INSERT = function(tableObj,item) | |
tableObj[#tableObj+1] = item | |
end | |
local REMOVE = function(tableObj,i) | |
tableObj[i] = nil | |
end | |
local getObject = function(Model, Class, Name) | |
for _, v in PAIRS(Model:GetChildren()) do | |
if v:IsA(Class) and v.Name == Name then | |
return v | |
end | |
end | |
return nil | |
end | |
local function hasAimWeld(v) | |
return CollectionService:HasTag(v,"AimPart_Custom") | |
end | |
local LMGPartList = { | |
"LidHinge"; | |
"Lid"; | |
"LidPart"; | |
"LidPartMainSight"; | |
} | |
local RevolverPartList = { | |
"RevolverHinge"; | |
"Carousel"; | |
"RevolverBarrel"; | |
} | |
local PumpActionShotgunPartList = { | |
"Pump"; | |
} | |
local StockParts = { | |
"StockMain"; | |
"Stock"; | |
} | |
local BipodPartList = { | |
"BipodYHinge"; | |
"LeftBipodHinge"; | |
"RightBipodHinge"; | |
"LeftBipodPart"; | |
"RightBipodPart"; | |
"BipodMountPart"; | |
}; | |
local function isPumpActionShotgunPart(v) | |
return (S.isPumpActionShotgun and not inList(v.Name,PumpActionShotgunPartList)) or not S.isPumpActionShotgun | |
end | |
local function isRevolverPart(v) | |
return (S.isRevolver and not inList(v.Name,RevolverPartList)) or not S.isRevolver | |
end | |
local function isLMGPart(v) | |
return (S.isLMG and not inList(v.Name,LMGPartList)) or not S.isLMG | |
end | |
local function isStockPart(v) | |
return ((S.hasFoldingStock) and (not inList(v.Name,StockParts)) or (not S.hasFoldingStock)) | |
end | |
local function isBipodPart(v) | |
return ((Gun:FindFirstChild("BipodMain") and not inList(v.Name,BipodPartList)) or not Gun:FindFirstChild("BipodMain")) | |
end | |
local BoltWelds = {} | |
function addBolt(bolt,slidepart) | |
if bolt:FindFirstChild("BoltRole") then | |
if bolt.BoltRole:IsA("StringValue") then | |
if bolt.Name == "Bolt" then | |
local bRole = bolt.BoltRole.Value | |
BoltWelds[bRole] = Instance.new("Motor6D") | |
BoltWelds[bRole].Name = "BoltWeld" | |
BoltWelds[bRole].Part0 = slidepart | |
BoltWelds[bRole].Part1 = bolt | |
BoltWelds[bRole].C0 = slidepart.CFrame:toObjectSpace(bolt.CFrame) | |
BoltWelds[bRole].C1 = CF() | |
BoltWelds[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 SearchResupply(ammoObj) | |
local AmmoRestore = false | |
local ResupplyValue = nil | |
if ammoObj:FindFirstChild('Resupply') or ammoObj.Parent:FindFirstChild('Resupply') then | |
AmmoRestore = true | |
if ammoObj:FindFirstChild('Resupply') then | |
ResupplyValue = ammoObj.ResupplyVal | |
elseif ammoObj.Parent:FindFirstChild('Resupply') then | |
ResupplyValue = ammoObj.Parent.ResupplyVal | |
end | |
end | |
return AmmoRestore, ResupplyValue | |
end | |
---------------------------------------------------------------------- | |
--------------------[ GET WELD CFRAMES ]------------------------------ | |
---------------------------------------------------------------------- | |
for _, v in pairs(Gun:GetChildren()) do | |
if v:IsA("BasePart") and v ~= Handle then | |
if v:FindFirstChild("mainWeld") then v.mainWeld:Destroy() end | |
if (not v:FindFirstChild("weldCF")) then | |
local weldCF = Instance.new("CFrameValue") | |
weldCF.Name = "weldCF" | |
weldCF.Value = Handle.CFrame:toObjectSpace(v.CFrame) | |
weldCF.Parent = v | |
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 | |
if S.isRevolver and not v.Name:find("Case") then | |
v:FindFirstChild("weldCF"):Destroy() | |
end | |
end | |
v.Anchored = true | |
v.CanCollide = true | |
end | |
end | |
Network.listen("Server","Fetch","gunSetup_"..tostring(Plyr.Value.UserId),function(player,Vars) | |
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 | |
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 | |
Grip = Instance.new("Motor6D") | |
Grip.Name = "RightGrip" | |
Grip.Part0 = Vars.RArm | |
Grip.Part1 = Handle | |
Grip.C0 = CF(0, -1, 0) * CFANG(-0.5 * math.pi, 0, 0) | |
Grip.C1 = S.equipSettings.GripC1 | |
Grip.Parent = Vars.RArm | |
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) | |
Network.listen("Server","Send","MuzzleFlash",function(player,main) | |
RemoteService.bounceOthers("Client","MuzzleFlash",main) | |
end) | |
--Network.listen("Server","Fetch","makeBullet_"..Plyr.Value.UserId,function(player,Mode,bulletDirection,Origin,ignoreList,gunIgnore) | |
-- local Origin = Origin | |
-- local Char = Gun.Parent | |
-- local ignoreModel = ignoreList[2] | |
-- local bulletCF = CF(Origin, Origin + bulletDirection) | |
-- local Bullet | |
-- if Mode ~= "STUN" then | |
-- | |
-- Bullet = OBJ("Part") | |
-- | |
-- Bullet.BrickColor = S.bulletSettings.Color | |
-- Bullet.Material = Enum.Material.Neon | |
-- Bullet.Name = "Bullet" | |
-- Bullet.CanCollide = false | |
-- Bullet.Size = S.bulletSettings.Size | |
-- Bullet.BottomSurface = "Smooth" | |
-- Bullet.TopSurface = "Smooth" | |
-- if S.bulletSettings.trueBolt then | |
-- local Mesh2 = game.ReplicatedStorage.BlasterEffects.boltMesh:Clone() | |
-- Mesh2.Parent = Bullet | |
-- | |
-- end | |
-- if not S.bulletSettings.trueBolt then | |
-- if MIN(S.bulletSettings.Size.X, S.bulletSettings.Size.Y, S.bulletSettings.Size.Z) < 0.2 then | |
-- local Mesh = OBJ("BlockMesh") | |
-- | |
-- Mesh.Scale = S.bulletSettings.Size / V3( | |
-- MAX(S.bulletSettings.Size.X, 0.2), | |
-- MAX(S.bulletSettings.Size.Y, 0.2), | |
-- MAX(S.bulletSettings.Size.Z, 0.2) | |
-- ) | |
-- Mesh.Parent = Bullet | |
-- | |
-- end | |
-- | |
-- end | |
-- else | |
-- Bullet = game.ReplicatedStorage.StunBullet:Clone() | |
-- end | |
-- | |
-- local BF = OBJ("BodyForce") | |
-- BF.force = V3(0, Bullet:GetMass() * (196.2 - S.bulletSettings.Acceleration), 0) | |
-- local BV = OBJ("BodyVelocity") | |
-- BV.MaxForce = V3(1000000,10000000,10000000) | |
-- BV.Velocity = bulletDirection * S.bulletSettings.Velocity | |
-- BV.Parent = Bullet | |
-- BF.Parent = Bullet | |
-- Bullet.Parent = gunIgnore | |
-- Bullet.CFrame = bulletCF + bulletDirection * S.bulletSettings.Size.Z / 2 | |
-- return Bullet | |
--end) | |
Network.listen("Server","Fetch","unSetupGun_"..Plyr.Value.UserId,function(player,gunParts) | |
for _, Tab in PAIRS(gunParts) do | |
Tab.Weld:Destroy() | |
Tab.Weld = nil | |
end | |
return true | |
end) | |
local function createFakeArm(...) | |
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(Plyr.Value.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 | |
Network.listen("Server","Fetch","CreateKnifeGrenade",function(player,weldNade,RightArm,GripC0,NadeC1) | |
local Knife = Instance.new("Part") | |
--Knife.BrickColor = S.TacticalGrenadeColor | |
Knife.Name = "Knife" | |
Knife.CanCollide = false | |
Knife.FormFactor = Enum.FormFactor.Custom | |
Knife.Size = V3(1, 1, 3) | |
local Mesh = Instance.new("SpecialMesh") | |
Mesh.MeshId = "http://www.roblox.com/asset/?id=12221720" | |
Mesh.MeshType = Enum.MeshType.FileMesh | |
Mesh.Scale = V3(0.5, 0.5, 0.5) | |
Mesh.Parent = Knife | |
if weldNade then | |
local Weld = Instance.new("Motor6D") | |
Weld.Part0 = RightArm | |
Weld.Part1 = Knife | |
Weld.Parent = Knife | |
end | |
Knife.Parent =workspace.ignoreModel.grenadeFolder | |
return Knife | |
end) | |
Network.listen("Server","Fetch","CreateGrenade",function(player,Type,weldNade,RightArm,GripC0) | |
local Grenade | |
if Type == 1 then | |
if S.grenadeSettings.Lethal.Type == 1 then | |
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Frag"):Clone() | |
elseif S.grenadeSettings.Lethal.Type == 4 then | |
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Molotov"):Clone() | |
elseif S.grenadeSettings.Lethal.Type == 2 then | |
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Sticky"):Clone() | |
end | |
elseif Type == 2 then | |
if S.grenadeSettings.Tactical.Type == 1 then | |
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Smoke"):Clone() | |
elseif S.grenadeSettings.Tactical.Type == 2 then | |
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Flashbang"):Clone() | |
end | |
end | |
Grenade:SetPrimaryPartCFrame(RightArm.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() | |
w.Parent = w.Part0 | |
part.Anchored = false | |
end | |
end | |
if weldNade then | |
local Weld = Instance.new("Motor6D") | |
Weld.Part0 = RightArm | |
Weld.Part1 = Grenade:WaitForChild("Center") | |
Weld.C0 = Grip.C0 | |
Weld.Parent = Grenade:WaitForChild("Center") | |
end | |
Grenade.Center.Anchored = false | |
Grenade.Parent = workspace.ignoreModel.grenadeFolder | |
return Grenade | |
end) | |
Network.listen("Server","Send","SetNadeCF",function(player,nade,cf) | |
nade.CFrame = cf | |
end) | |
Network.listen("Server","Send","SetNadeVelocity",function(player,nade,vel) | |
nade.Velocity = vel | |
end) | |
Network.listen("Server","Send","SetNadeRVelocity",function(player,nade,vel) | |
nade.RotVelocity = vel | |
end) | |
Network.listen("Server","Send","StickNade",function(player,nade,Obj,nade,gCF) | |
if player ~= Plyr.Value then return end | |
local W = Instance.new("Motor6D") | |
W.Name = "Semtex" | |
W.Part0 = nade:WaitForChild("Center",200) | |
W.Part1 = Obj | |
W.C0 = gCF:toObjectSpace(Obj.CFrame) | |
W.Parent = nade | |
nade.ChildRemoved:connect(function(C) | |
if C.Name == "Semtex" then | |
local W = Instance.new("Motor6D") | |
W.Name = "Semtex" | |
W.Part0 = nade:WaitForChild("Center",200) | |
W.Part1 = Obj | |
W.C0 = gCF:toObjectSpace(Obj.CFrame) | |
W.Parent = nade | |
end | |
end) | |
end) | |
Network.listen("Server","Send","DestroyNade",function(player,nade) | |
if nade then | |
if nade.Parent == workspace.ignoreModel.grenadeFolder then | |
nade:Destroy() | |
end | |
end | |
end) | |
Network.listen("Server","Fetch","MakeArms",function(player,Vars) | |
local armModel = OBJ("Model") | |
armModel.Parent = Vars.playerFolder | |
local fakeLArm = createFakeArm("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("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(Gun.Parent:GetChildren()) do | |
if Obj:IsA("CharacterMesh") then | |
Obj:Clone().Parent = armModel | |
end | |
end | |
end | |
for _,Obj in PAIRS(Gun.Parent:GetChildren()) do | |
if Obj:IsA("Shirt") then | |
Obj:Clone().Parent = armModel | |
end | |
end | |
return armModel | |
end) | |
Network.listen("Server","Fetch","Blood_"..Plyr.Value.UserId,function(player, H, P, D, gunIgnore, S) | |
local bloodCF = CF(P, P + D) * CFANG(RAD(-90), 0, 0) | |
local Blood = OBJ("Part") | |
Blood.Transparency = 1 | |
Blood.Anchored = true | |
Blood.CanCollide = false | |
Blood.FormFactor = "Custom" | |
Blood.Size = V3(0.2, 1, 0.2) | |
Blood.TopSurface = 0 | |
Blood.BottomSurface = 0 | |
local Particles = OBJ("ParticleEmitter") | |
Particles.Color = CSEQ(S.bloodSettings.Color) | |
Particles.LightEmission = 0 | |
Particles.Size = NSEQ(S.bloodSettings.Size) | |
Particles.Texture = S.bloodSettings.Texture | |
Particles.Transparency = NSEQ( | |
{ | |
NumberSequenceKeypoint.new(0, S.bloodSettings.startTransparency); | |
NumberSequenceKeypoint.new(1, 1); | |
} | |
) | |
Particles.EmissionDirection = Enum.NormalId.Top | |
Particles.Lifetime = NRANGE(S.bloodSettings.Lifetime - 0.05, S.bloodSettings.Lifetime + 0.05) | |
Particles.Rate = S.bloodSettings.Rate | |
Particles.Rotation = NRANGE(0, 90) | |
Particles.Speed = NRANGE(S.bloodSettings.Speed) | |
Particles.VelocitySpread = S.bloodSettings.Spread | |
Particles.Parent = Blood | |
Blood.Parent = gunIgnore | |
Blood.CFrame = bloodCF | |
if (not H.Anchored) then | |
local Weld = OBJ("Weld", Blood) | |
Weld.Part0 = H | |
Weld.Part1 = Blood | |
Weld.C0 = H.CFrame:toObjectSpace(bloodCF) | |
Blood.Anchored = false | |
end | |
delay(0.15, function() | |
Particles.Enabled = false | |
wait(S.bloodSettings.Lifetime + 0.05) | |
Blood:Destroy() | |
end) | |
return true | |
end) | |
--Network.listen("Server","Fetch","Trail_"..Plyr.Value.UserId,function(player,Origin, P, gunIgnore, S) | |
-- local Trail = OBJ("Part") | |
-- Trail.BrickColor = S.trailSettings.Color | |
-- Trail.Transparency = S.trailSettings.Transparency | |
-- Trail.Anchored = true | |
-- Trail.CanCollide = false | |
-- Trail.Size = V3(1, 1, 1) | |
-- local Mesh = OBJ("CylinderMesh") | |
-- Mesh.Offset = V3(0, -(P - Origin).magnitude / 2, 0) | |
-- Mesh.Scale = V3(S.trailSettings.Thickness, (P - Origin).magnitude, S.trailSettings.Thickness) | |
-- Mesh.Parent = Trail | |
-- Trail.Parent = gunIgnore | |
-- Trail.CFrame = CF(Origin, P) * CFANG(RAD(90), 0, 0) | |
-- delay(S.trailSettings.visibleTime, function() | |
-- if S.trailSettings.disappearTime > 0 then | |
-- local t0 = tick() | |
-- while true do | |
-- local Alpha = math.min((tick() - t0) / S.trailSettings.disappearTime, 1) | |
-- Trail.Transparency = numLerp(S.trailSettings.Transparency, 1, Alpha) | |
-- if Alpha == 1 then break end | |
-- RS.Heartbeat:wait() | |
-- end | |
-- Trail:Destroy() | |
-- else | |
-- Trail:Destroy() | |
-- end | |
-- end) | |
-- result = true | |
-- | |
--end) | |
local function Damage(player,Humanoid,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] | |
if Humanoid.Health ~= 0 then | |
local hitHumanoid = nil | |
if not H then return end | |
if H.Parent ~= nil then | |
if H.Parent:IsA("Accoutrement") or H.Parent:FindFirstChild("Middle") then | |
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(player, Humanoid, 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(hitHumanoid,player) then | |
local chosenDamage = 0 | |
local headShot = false | |
if H.Name == "Head" then | |
headShot = true | |
chosenDamage = RPGM.Combat.HeadshotOffset(getBaseDamage(Dist,Cartridge),RANDOM(Gun.HeadshotDamageMagnitude.Value/(2 - (hVal/BindableService.fetch("GetAttribute",Plyr.Value,"Dexterity"))),Gun.HeadshotDamageMagnitude.Value)) * (hVal + 0.1) | |
elseif H.Name == "Torso" then | |
chosenDamage = (RPGM.Combat.RangedPower(BindableService.fetch("GetPlayerLevel",Plyr.Value),BindableService.fetch("GetAttribute",Plyr.Value,"Dexterity"),RANDOM(getBaseDamage(Dist,Cartridges[CartridgeName])/(2 - (cVal/BindableService.fetch("GetAttribute",Plyr.Value,"Dexterity"))),getBaseDamage(Dist,Cartridge)))) | |
else | |
chosenDamage = (RPGM.Combat.RangedPower(BindableService.fetch("GetPlayerLevel",Plyr.Value),BindableService.fetch("GetAttribute",Plyr.Value,"Dexterity"),RANDOM(getBaseDamage(Dist,Cartridges[CartridgeName])/(2 - (lVal/BindableService.fetch("GetAttribute",Plyr.Value,"Dexterity"))),getBaseDamage(Dist,Cartridge)))) | |
end | |
local sniperRand | |
if H.Name == "Head" and S.sniperDamage then | |
sniperRand = RANDOM(1,2) | |
chosenDamage = (sniperRand == 2 and hitHumanoid.Health or chosenDamage) | |
end | |
tagHumanoid(hitHumanoid,Plyr.Value,chosenDamage,hitHumanoid.Health,headShot) | |
hitHumanoid:TakeDamage(chosenDamage) | |
Network.send("Client",player,"markHit_"..Plyr.Value.UserId) | |
end | |
end | |
return hitHumanoid | |
end | |
end | |
end | |
Network.setupDamageListener(Damage) | |
function Map(Val, fromLow, fromHigh, toLow, toHigh) | |
return (Val - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow | |
end | |
function getBaseDamage(Dist,Cartridge) | |
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 | |
local function makeImpact(player, H, P, N, D, humanoidFound) | |
RemoteService.bounceOthers("Client",player,"ShowImpactFromPoint",H,P,N,D,humanoidFound,S.roundsPerMin) | |
end | |
Network.listen("Server","Send","bulletImpact_"..Plyr.Value.UserId,makeImpact) | |
Network.listen("Server","Send","SetJointC0_"..Plyr.Value.UserId,function(player,Joint, C0) | |
Joint.C0 = C0 | |
end) | |
Network.listen("Server","Send","SetJointC1_"..Plyr.Value.UserId,function(player,Joint,C1) | |
Joint.C1 = C1 | |
end) | |
Network.listen("Server","Send","changeGripC1_"..Plyr.Value.UserId,function(player,Grip,GripC1) | |
Grip.C1 = GripC1 | |
end) | |
Network.listen("Server","Send","changeAnimC1_"..Plyr.Value.UserId,function(player,animWeld,animC0,animC1) | |
animWeld.C0 = animC0 | |
animWeld.C1 = animC1 | |
end) | |
Network.listen("Server","Send","changeBoltC1_"..Plyr.Value.UserId,function(player, boltW,boltCF) | |
if Gun:FindFirstChild("SlidePart") then | |
if inList(boltW,BoltWelds) then | |
boltW.C1 = boltCF | |
end | |
end | |
end) | |
Network.listen("Server","Send","destroyGunIgnore_"..Plyr.Value.UserId,function(player,gunIgnore) | |
if player == Plyr.Value then | |
gunIgnore:Destroy() | |
end | |
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) | |
runAsync(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 | |
Network.listen("Server","Send","Shockwave_"..Plyr.Value.UserId,makeShockwave) | |
Network.listen("Server","Send","FireExplosive",function(player,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 | |
makeImpact(player, H, P, N, bulletDirection, false, gunIgnore, S) | |
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(Char)) 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) | |
Network.send("Client",player,"markHit_"..Plyr.Value.UserId) | |
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) | |
Network.send("Client",player,"markHit_"..player.UserId) | |
end | |
end | |
end | |
end) | |
E.Parent = game.Workspace | |
if S.singleUse then | |
local result = Network.fetch("Client",player,"Dispose") | |
BindableService.fetch("SwitchLoadoutItem",player,"Primary") | |
Gun:Destroy() | |
end | |
end | |
end) | |
Network.listen("Server","Send","ShowRegularArms",function(player,LArm,RArm) | |
LArm.Transparency = 0 | |
RArm.Transparency = 0 | |
end) | |
Network.listen("Server","Send","ChangeRLegWeldC1_"..Plyr.Value.UserId,function(player,RLegWeld,legC1) | |
RLegWeld.C1 = legC1 | |
end) | |
Network.listen("Server","Send","changeHeadC1_"..Plyr.Value.UserId,function(player,headWeld, headC1) | |
headWeld.C1 = headC1 | |
end) | |
Network.listen("Server","Send","ResetShoulders_"..Plyr.Value.UserId,function(player,Shoulders,LArm,RArm) | |
Shoulders.Right.Part1 = RArm | |
Shoulders.Left.Part1 = LArm | |
end) | |
Network.listen("Server","Send","DestroyHeadWeld_"..Plyr.Value.UserId,function(player,headWeld) | |
headWeld:Destroy() | |
end) | |
Network.listen("Server","Send","changeLLegWeldC1_"..Plyr.Value.UserId,function(player,LLegWeld, legC1) | |
LLegWeld.C1 = legC1 | |
end) | |
Network.listen("Server","Send","RemoveArmModel",function(player,armModel) | |
armModel:Destroy() | |
end) | |
Network.listen("Server","Send","changeRWeldC1_"..Plyr.Value.UserId,function(player, RWeld,rC1) | |
RWeld.C1 = rC1 | |
end) | |
Network.listen("Server","Send","changeLWeldC1_"..Plyr.Value.UserId,function(player, LWeld,lC1) | |
LWeld.C1 = lC1 | |
end) | |
Network.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) | |
Network.listen("Server","Send","ReplicateBullet_"..Plyr.Value.UserId,function(player,Direction,bCFrame,cartName) | |
RemoteService.bounceOthers("Client",Plyr.Value,"MakeBullet",Direction,bCFrame,cartName) | |
end) | |
--Gun.BulletObj.Changed:connect(function(bullet) | |
-- if bullet then | |
-- local Bullet = bullet:Clone() | |
-- | |
-- end | |
--end) | |
local Humanoid = Character.Humanoid | |
local Torso = Character.Torso | |
function WeldSheathedWeapon(sm) | |
local gunParts = {} | |
BoltWelds = {} | |
local Handle = sm.Handle | |
for _, weld in pairs(sm.Handle:GetChildren()) do | |
if weld.Name == "StockPartWeld" then | |
weld.Part1 = nil | |
elseif weld.Name == "LidHingeWeld" then | |
weld.Part1 = nil | |
elseif weld.Name == "LidWeld" then | |
weld.Part1 = nil | |
elseif weld.Name == "PumpWeld" then | |
weld.Part1 = nil | |
elseif weld.Name == "StockMainWeld" then | |
weld.Part1 = nil | |
elseif weld.Name == "RevolverWeld" then | |
weld.Part1 = nil | |
elseif weld.Name == "BipodWeld" then | |
weld.Part1 = nil | |
elseif weld:IsA("JointInstance") then | |
weld:Destroy() | |
end | |
end | |
if S.isLMG then | |
sm.Lid.Anchored = true | |
sm.LidHinge.Anchored = true | |
end | |
for _, v in pairs(sm:GetChildren()) do | |
if v:IsA("BasePart") and v ~= sm.Handle and (not hasAimWeld(v)) and v.Name ~= "Bolt" and (sm == Gun and isLMGPart(v) or (sm ~= Gun)) and (sm == Gun and isRevolverPart(v) or (sm ~= Gun)) and (sm == Gun and isPumpActionShotgunPart(v) or (sm ~= Gun)) and (sm == Gun and isStockPart(v) or (sm ~= Gun)) then | |
if v:FindFirstChild("mainWeld") then v.mainWeld:Destroy() end | |
if (not v:FindFirstChild("weldCF")) then | |
local weldCF = Instance.new("CFrameValue") | |
weldCF.Name = "weldCF" | |
weldCF.Value = Handle.CFrame:toObjectSpace(v.CFrame) | |
weldCF.Parent = v | |
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 | |
if S.isRevolver and not v.Name:find("Case") and sm == Gun then | |
v:FindFirstChild("weldCF"):Destroy() | |
end | |
end | |
end | |
if v:IsA("BasePart") then | |
v.Anchored = true | |
v.CanCollide = false | |
end | |
end | |
for _, gunPart in pairs(sm:GetChildren()) do | |
if gunPart.Name == "Bolt" and gunPart:FindFirstChild("BoltRole") then | |
if gunPart:FindFirstChild("SightWeld") then | |
gunPart.SightWeld:Destroy() | |
end | |
gunPart.CanCollide = false | |
addBolt(gunPart,sm.SlidePart) | |
end | |
end | |
if S.boltSettings.weldMainSight and sm:FindFirstChild("MainSight") then | |
if sm.MainSight:FindFirstChild("weldCF") then | |
sm.MainSight.weldCF:Destroy() | |
end | |
local sightWeld = Instance.new("Weld") | |
sightWeld.Name = "SightWeld" | |
sightWeld.Part0 = findBolt(sm,"Main") | |
sightWeld.Part1 = sm.MainSight | |
sightWeld.C0 = findBolt(sm,"Main").CFrame:toObjectSpace(sm.MainSight.CFrame) | |
sightWeld.C1 = CF() | |
sightWeld.Parent = findBolt(sm,"Main") | |
sm.MainSight.Anchored = false | |
end | |
if S.isLMG then | |
if sm:FindFirstChild("LidHinge") and sm == Gun then | |
if sm.LidHinge:FindFirstChild("weldCF") then | |
sm.LidHinge:FindFirstChild("weldCF"):Destroy() | |
end | |
if sm.Lid:FindFirstChild("weldCF") then | |
sm.Lid:FindFirstChild("weldCF"):Destroy() | |
end | |
for _, v in pairs(sm:GetChildren()) do | |
if v:IsA("BasePart") and (v.Name == "LidPart" or v.Name == "LidPartMainSight") then | |
if v:FindFirstChild("weldCF") then | |
v.weldCF:Destroy() | |
end | |
end | |
end | |
if not sm.Handle:FindFirstChild("LidHinge") and not sm.LidHinge:FindFirstChild("weldCF") then | |
for _, v in pairs(sm:GetChildren()) do | |
if v:IsA("BasePart") and (v.Name == "LidPart" or v.Name == "LidPartMainSight") then | |
local w = Instance.new("Weld") | |
w.Name = "LidAttachment" | |
w.Part0 = sm.Lid | |
w.Part1 = v | |
w.C0 = sm.Lid.CFrame:toObjectSpace(v.CFrame) | |
w.Parent = sm.Lid | |
v.Anchored = false | |
end | |
end | |
local HingeWeld = Instance.new("Motor6D") | |
HingeWeld.Name = "LidHinge" | |
HingeWeld.Part0 = sm.LidEffector | |
HingeWeld.Part1 = sm.LidHinge | |
HingeWeld.C0 = sm.LidEffector.CFrame:toObjectSpace(sm.LidHinge.CFrame) | |
HingeWeld.C1 = CF() | |
HingeWeld.Parent = HingeWeld.Part0 | |
local HingeWeld1 = Instance.new("Weld") | |
HingeWeld1.Name = "LidAttachment" | |
HingeWeld1.Part0 = sm.LidHinge | |
HingeWeld1.Part1 = sm.Lid | |
HingeWeld1.C0 = sm.LidHinge.CFrame:toObjectSpace(sm.Lid.CFrame) | |
HingeWeld1.C1 = CF() | |
HingeWeld1.Parent = HingeWeld1.Part0 | |
end | |
end | |
elseif S.isRevolver then | |
if sm:FindFirstChild("RHPart") and sm == Gun then | |
if sm.Carousel:FindFirstChild("weldCF") then | |
sm.Carousel:FindFirstChild("weldCF"):Destroy() | |
end | |
if sm.RevolverHinge:FindFirstChild("weldCF") then | |
sm.RevolverHinge:FindFirstChild("weldCF"):Destroy() | |
end | |
if sm.RevolverBarrel:FindFirstChild("weldCF") then | |
sm.RevolverBarrel:FindFirstChild("weldCF"):Destroy() | |
end | |
local RevolverHingeMotor = Instance.new("Motor6D") | |
RevolverHingeMotor.Name = "RevolverHinge" | |
RevolverHingeMotor.Part0 = sm.RHPart | |
RevolverHingeMotor.Part1 = sm.RevolverHinge | |
RevolverHingeMotor.C0 = sm.RHPart.CFrame:toObjectSpace(sm.RevolverHinge.CFrame) | |
RevolverHingeMotor.C1 = CFrame.new() | |
RevolverHingeMotor.Parent = sm.RHPart | |
local RevolverBarrelWeld = Instance.new("Motor6D") | |
RevolverBarrelWeld.Name = "BarrelAttachment" | |
RevolverBarrelWeld.Part0 = sm.RevolverHinge | |
RevolverBarrelWeld.Part1 = sm.RevolverBarrel | |
RevolverBarrelWeld.C0 = sm.RevolverHinge.CFrame:toObjectSpace(sm.RevolverBarrel.CFrame) | |
RevolverBarrelWeld.Parent = sm.RevolverHinge | |
Gun.RevolverHinge.Anchored = false | |
Gun.RevolverBarrel.Anchored = false | |
local RevolverCarouselMotor = Instance.new("Motor6D") | |
RevolverCarouselMotor.Name = "CarouselMotor" | |
RevolverCarouselMotor.Part0 = sm.RHPart | |
RevolverCarouselMotor.Part1 = sm.Carousel | |
RevolverCarouselMotor.C0 = sm.RHPart.CFrame:toObjectSpace(sm.Carousel.CFrame) | |
RevolverCarouselMotor.C1 = CFrame.new() | |
RevolverCarouselMotor.Parent = sm.RHPart | |
for _, part in pairs(sm:GetChildren()) do | |
if part:IsA("BasePart") then | |
if part.Name:sub(1,3) == "Mag" and not part.Name:find("Case") then | |
local MagWeld = Instance.new("Weld") | |
MagWeld.Part0 = sm.Carousel | |
MagWeld.Part1 = part | |
MagWeld.C0 = sm.Carousel.CFrame:toObjectSpace(part.CFrame) | |
MagWeld.C1 = CF() | |
MagWeld.Parent = sm.Carousel | |
part.Anchored = false | |
end | |
end | |
end | |
sm.Carousel.Anchored = false | |
end | |
elseif S.isPumpActionShotgun then | |
if sm:FindFirstChild("PumpPart") and sm == Gun then | |
if sm.Pump:FindFirstChild("weldCF") then | |
sm.Pump:FindFirstChild("weldCF"):Destroy() | |
end | |
local PumpSlide = Instance.new("Motor6D") | |
PumpSlide.Name = "PumpSlide" | |
PumpSlide.Part0 = sm.PumpPart | |
PumpSlide.Part1 = sm.Pump | |
PumpSlide.C0 = sm.PumpPart.CFrame:toObjectSpace(sm.Pump.CFrame) | |
PumpSlide.C1 = CF() | |
PumpSlide.Parent = sm.PumpPart | |
PumpSlide.Part1.Anchored = false | |
end | |
end | |
if S.hasFoldingStock and sm == Gun then | |
for _, part in pairs(sm:GetChildren()) do | |
if part:IsA("BasePart") and part ~= sm.StockMain and part ~= sm.StockHinge then | |
if part.Name == "Stock" then | |
local weld = Instance.new("Weld") | |
weld.Name = "StockWeld" | |
weld.Part0 = sm.StockMain | |
weld.Part1 = part | |
weld.C0 = sm.StockMain.CFrame:toObjectSpace(part.CFrame) | |
weld.Parent = sm.StockMain | |
part.Anchored = false | |
end | |
end | |
end | |
local StockHingeWeld = Instance.new("Motor6D") | |
StockHingeWeld.Name = "StockFoldHinge" | |
StockHingeWeld.Part0 = sm.StockHinge | |
StockHingeWeld.Part1 = sm.StockMain | |
StockHingeWeld.C0 = sm.StockHinge.CFrame:toObjectSpace(sm.StockMain.CFrame) | |
StockHingeWeld.C1 = CF() | |
StockHingeWeld.Parent = sm.StockHinge | |
sm.StockMain.Anchored = false | |
sm.StockHinge.Anchored = false | |
end | |
if sm:FindFirstChild("BipodMain") then | |
local MountWeld = Instance.new("Motor6D") | |
MountWeld.Name = "MountWeld" | |
MountWeld.Part0 = sm.BipodMain | |
MountWeld.Part1 = sm.BipodMountPart | |
MountWeld.C0 = sm.BipodMain.CFrame:toObjectSpace(sm.BipodMountPart.CFrame) | |
MountWeld.Parent = MountWeld.Part0 | |
sm.BipodMountPart.Anchored = false | |
local YHinge = Instance.new("Motor6D") | |
YHinge.Name = "BipodVertHinge" | |
YHinge.Part0 = sm.BipodMain | |
YHinge.Part1 = sm.BipodYHinge | |
YHinge.C0 = sm.BipodMain.CFrame:toObjectSpace(sm.BipodYHinge.CFrame) | |
YHinge.Parent = YHinge.Part0 | |
sm.BipodYHinge.Anchored = false | |
for _, part in pairs(sm:GetChildren()) do | |
if part:IsA("BasePart") and part.Name == "LeftBipodPart" then | |
local lBW = Instance.new("Weld") | |
lBW.Name = "BipodLegWeld" | |
lBW.Part0 = sm.LeftBipodHinge | |
lBW.Part1 = part | |
lBW.C0 = sm.LeftBipodHinge.CFrame:toObjectSpace(part.CFrame) | |
lBW.Parent = lBW.Part0 | |
part.Anchored = false | |
end | |
end | |
local XWeldLeft = Instance.new("Weld") | |
XWeldLeft.Name = "BipodLeftWeld" | |
XWeldLeft.Part0 = sm.BipodYHinge | |
XWeldLeft.Part1 = sm.LeftBipodHinge | |
XWeldLeft.C0 = sm.BipodYHinge.CFrame:toObjectSpace(sm.LeftBipodHinge.CFrame) | |
XWeldLeft.C1 = CFANG(RAD(-0),0,0) | |
XWeldLeft.Parent = sm.BipodYHinge | |
sm.LeftBipodHinge.Anchored =false | |
for _, part in pairs(sm:GetChildren()) do | |
if part:IsA("BasePart") and part.Name == "RightBipodPart" then | |
local lBW = Instance.new("Weld") | |
lBW.Name = "BipodLegWeld" | |
lBW.Part0 = sm.RightBipodHinge | |
lBW.Part1 = part | |
lBW.C0 = sm.RightBipodHinge.CFrame:toObjectSpace(part.CFrame) | |
lBW.Parent = lBW.Part0 | |
part.Anchored = false | |
end | |
end | |
local XWeldRight = Instance.new("Weld") | |
XWeldRight.Name = "BipodRightWeld" | |
XWeldRight.Part0 = sm.BipodYHinge | |
XWeldRight.Part1 = sm.RightBipodHinge | |
XWeldRight.C0 = sm.BipodYHinge.CFrame:toObjectSpace(sm.RightBipodHinge.CFrame) | |
XWeldRight.C1 = CFANG(RAD(S.bipodspread and S.bipodspread or -0),0,0) | |
XWeldRight.Parent = sm.BipodYHinge | |
sm.RightBipodHinge.Anchored =false | |
end | |
for _, v in pairs(sm:GetChildren()) do | |
if v:FindFirstChild("weldCF") and v.Name ~= "Bolt" then | |
gunParts[#gunParts+1] = {Obj = v, Weld = nil} | |
end | |
end | |
for _, Tab in pairs(gunParts) do | |
local Weld = Instance.new("Weld") | |
if Tab.Obj.Name == "LidHinge" then | |
Weld.Name = "LidHingeWeld" | |
elseif Tab.Obj.Name == "Lid" then | |
Weld.Name = "LidWeld" | |
elseif Tab.Obj.Name == "Pump" then | |
Weld.Name = "PumpWeld" | |
elseif Tab.Obj.Name == "Stock" then | |
Weld.Name = "StockPartWeld" | |
elseif Tab.Obj.Name == "StockMain" then | |
Weld.Name = "StockMainWeld" | |
elseif inList(Tab.Obj.Name, BipodPartList) then | |
Weld.Name = "BipodWeld" | |
elseif inList(Tab.Obj.Name, RevolverPartList) then | |
Weld.Name = "RevolverWeld" | |
else | |
Weld.Name = "MainWeld" | |
end | |
Weld.Part0 = Handle | |
Weld.Part1 = Tab.Obj | |
Weld.C0 = Tab.Obj.weldCF.Value | |
Weld.Parent = Handle | |
Tab.Weld = Weld | |
Tab.Obj.Anchored = false | |
Tab.Obj.CanCollide = false | |
end | |
sm.SlidePart.Anchored = false | |
sm.SlidePart.CanCollide = true | |
sm.Handle.Anchored = false | |
sm.Handle.CanCollide = false | |
if S.isLMG then | |
sm.LidHinge.Anchored = false | |
sm.LidHinge.CanCollide = false | |
sm.Lid.Anchored = false | |
sm.Lid.CanCollide = false | |
end | |
if S.isPumpActionShotgun then | |
sm.Pump.Anchored = false | |
end | |
end | |
local sheatheModel = Instance.new("Model") | |
sheatheModel.Name = Gun.Name .. "_Holster" | |
local gunRef = Instance.new("ObjectValue") | |
gunRef.Name = "Gun" | |
gunRef.Value = Gun | |
gunRef.Parent = sheatheModel | |
local RLeg = Character:FindFirstChild("Right Leg") | |
local LLeg = Character:FindFirstChild("Left Leg") | |
local SW = Instance.new("Motor6D") | |
SW.Name = "SheatheWeld" | |
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 | |
function sheatheGun() | |
local Torso = Character.Torso | |
local gunParts = {} | |
for _, weld in pairs(BoltWelds) do | |
weld:Destroy() | |
end | |
if Torso then | |
for _, part in pairs(Gun:GetChildren()) do | |
if part:IsA("BasePart") and part ~= Handle then | |
local part2 = part:Clone() | |
part2.Parent = sheatheModel | |
part2.CanCollide = false | |
elseif part == Handle then | |
local handle2 = part:Clone() | |
handle2:BreakJoints() | |
handle2.Parent = sheatheModel | |
end | |
end | |
for _, Obj in pairs(sheatheModel:GetChildren()) do | |
if Obj:IsA("BasePart") then | |
local Weld = Instance.new("Weld") | |
Weld.Name = "MainWeld" | |
Weld.Part0 =sheatheModel. Handle | |
Weld.Part1 = Obj | |
Weld.C0 = sheatheModel.Handle.CFrame:toObjectSpace(Obj.CFrame) | |
Weld.Parent = sheatheModel.Handle | |
Obj.Anchored = false | |
Obj.CanCollide = false | |
end | |
end | |
SW.Part1 = sheatheModel.Handle | |
if guntype == 1 then | |
if weldmode == 1 then | |
SW.C1 = CF(distance *-1, 0.25 +y, -0.75 +x *-1) * CFANG(RAD(rotation *-1), (math.pi / 2), 0) | |
elseif weldmode == 2 then | |
SW.C1 = CF(distance, 0.25 +y, -0.75 +x *-1) * CFANG(RAD(rotation *-1), (math.pi / 2 ) *-1, 0) | |
elseif weldmode == 3 then | |
SW.C1 = CF(distance *-1, -0.1+y, 0.2 +x *-1) * CFANG(RAD(rotation), (math.pi / 2), -1.5) | |
elseif weldmode == 4 then | |
SW.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 | |
SW.C1 = CF(distance *-1, 0.25+y, -0.5 +x *-1) * CFANG(RAD(rotation *-1), math.pi / 2, 0) | |
elseif weldmode == 2 then | |
SW.C1 = CF(distance, 0.25 +y, -0.5 +x *-1) * CFANG(RAD(rotation *-1), math.pi / 2 *-1, 0) | |
elseif weldmode == 3 then | |
SW.C1 = CF(distance *-1, 0.25 +y, -0.5 +x *-1) * CFANG(RAD(rotation), math.pi / 2, 0) | |
elseif weldmode == 4 then | |
SW.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 | |
SW.C1 = CF(distance *-1, 0 +y, -0.25 +x *-1) * CFANG(math.pi / 2, 0, 0) | |
elseif weldmode == 2 then | |
SW.C1 = CF(distance, 0 +y, -0.25 +x *-1) * CFANG(math.pi / 2, 0, 0) | |
elseif weldmode == 3 then | |
SW.C1 = CF(distance *-1, 0 +y, 0.25 +x) * CFANG(math.pi / 2 , math.pi / 2, 0) | |
elseif weldmode == 4 then | |
SW.C1 = CF(distance, 0 +y, 0.25 +x) * CFANG(math.pi / 2 , math.pi / 2 *-1, 0) | |
end | |
end | |
sheatheModel.Parent = Char | |
Handle.Anchored = false | |
Handle.CanCollide = false | |
end | |
end | |
Network.listen("Server","Fetch","GetBoltWelds",function(player) | |
return BoltWelds | |
end) | |
function unSheatheGun() | |
local Torso = Char.Torso | |
sheatheModel:ClearAllChildren() | |
WeldSheathedWeapon(Gun) | |
if Torso then | |
if SW then | |
SW.Part1 = nil | |
end | |
end | |
end | |
Network.startServer(); | |
Gun.Equipped:connect(function() | |
unSheatheGun() | |
local CamoId = Gun.CamoId | |
for _, part in pairs(Gun:GetChildren()) do | |
if part:IsA("BasePart") then | |
if part:FindFirstChildOfClass("Texture") then | |
for _, texture in pairs(part:GetChildren()) do | |
if texture:IsA("Texture") then | |
texture.Texture = CamoId.Value | |
end | |
end | |
end | |
end | |
end | |
Handle.Anchored = false | |
Handle.CanCollide = true | |
if game.PlaceId == 338296377 then | |
local OpticsAttachment = BindableService.fetch("GetAttachmentSlot",Plyr.Value,Gun.Name,"Optics") | |
if (#OpticsAttachment > 0) then | |
Gun.BlackScope.Value = BindableService.fetch("IsAttachmentBlackScoped",OpticsAttachment) | |
Gun.FOV.Value = BindableService.fetch("GetAttachmentFOV",OpticsAttachment) or S.aimSettings.InFOV | |
else | |
Gun.BlackScope.Value = S.guiScope | |
Gun.FOV.Value = S.aimSettings.InFOV | |
Gun.ScopeId.Value = S.scopeSettings.Id or "" | |
end | |
else | |
Gun.BlackScope.Value = S.guiScope | |
Gun.FOV.Value = S.aimSettings.InFOV | |
Gun.ScopeId.Value = S.scopeSettings.Id or "" | |
end | |
Network.enable() | |
end) | |
Gun.Unequipped:connect(function() | |
sheatheGun() | |
Grip:Destroy() | |
Network.reset() | |
end) | |
sheatheGun(true) | |
Gun.Welded.Value = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment