deve690

Untitled

May 30th, 2024 (edited)
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 34.20 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local UserInputService = game:GetService("UserInputService")
  3. local Assets = ReplicatedStorage:WaitForChild("Assets")
  4. local TweenService = game:GetService("TweenService")
  5. local RunService = game:GetService("RunService")
  6. local Lighting = game:GetService("Lighting")
  7. local Players = game:GetService("Players")
  8. local Debris = game:GetService("Debris")
  9.  
  10.  
  11. local LocalNetwork = ReplicatedStorage:WaitForChild("LocalNetwork")
  12. local CheckEvent = LocalNetwork:WaitForChild("CheckStats")
  13. local BombEvent = LocalNetwork:WaitForChild("BombSIgnal")
  14. local WinsEvent = LocalNetwork:WaitForChild("Wins")
  15.  
  16. local OwnLungs = CheckEvent:InvokeServer(714321297)
  17.  
  18.  
  19. local player = Players.LocalPlayer
  20. local character = player.Character or player.CharacterAdded:Wait()
  21. local mouse = player:GetMouse()
  22. local camera = workspace.CurrentCamera
  23. local scopeActivated = false
  24. local playerGui = player:WaitForChild("PlayerGui")
  25. local scopeGui = playerGui:WaitForChild("ScopeGUI")["Scope" .. player:WaitForChild("CNFG"):WaitForChild("Scope").Value]
  26.  
  27. local FireBTN = player.PlayerGui:WaitForChild("Phone"):WaitForChild("Frame"):WaitForChild("FireBTN")
  28. local LungsBTN = player.PlayerGui:WaitForChild("Phone"):WaitForChild("Frame"):WaitForChild("LungsBTN")
  29.  
  30. local Spring = require(Assets.Modules.Spring)
  31. local Network = require(Assets.Modules.Network)
  32.  
  33. local humanoid = character:WaitForChild("Humanoid")
  34.  
  35. local neck = character.Torso:WaitForChild("Neck")
  36. local defaultNeck = neck.C0
  37.  
  38. local lastGurgle
  39. local rightShoulder, leftShoulder = character.Torso:WaitForChild("Right Shoulder"), character.Torso:WaitForChild("Left Shoulder")
  40.  
  41. local config = {
  42.     blood_timeout = 2;
  43.     meat_timeout = 2;
  44.     blood_cleanup_time = 5;
  45.     blood_cleanup_animation_time = 2.5;
  46.  
  47.     max_blood_parts = 1000;
  48.     max_wound_parts = 20;
  49.     max_meat_parts = 80;
  50.     blood_render_distance = 150065;
  51.     wound_render_distance = 60;
  52.     meat_render_distance = 40;
  53.     render_process = 1 / 30;
  54.     decal_cleanup_time = 10;
  55.     meat_cleanup_time = 5;
  56.  
  57.     combat_time = 1;
  58.  
  59.     default_debug_clean_time = 5;
  60.     debug = false;
  61. }
  62.  
  63. local springCam = Spring.new(Vector3.new())
  64. springCam.Speed = 1
  65. springCam.Damper = 0
  66.  
  67. local lastActive = 0
  68. local delay = 0
  69. local equipDelay = 0
  70. local neckTilt = 0
  71. local aimFOV = 0
  72. local cameraOffset = 1.5
  73. local DOFPos = Vector3.new()
  74.  
  75. local default_sens = UserInputService.MouseDeltaSensitivity
  76.  
  77. local bloodParts = {}
  78. local woundParts = {}
  79. local meatParts = {}
  80. local tools = {}
  81.  
  82. local equippingGun = false
  83. local gunTool
  84.  
  85. local params = RaycastParams.new()
  86. params.FilterDescendantsInstances = {workspace.Ignored, workspace.Characters}
  87. params.IgnoreWater = true
  88. params.CollisionGroup = "Raycast"
  89. params.FilterDescendantsInstances = {character}
  90.  
  91. local bodyGyro = Instance.new("BodyGyro")
  92. bodyGyro.D = 250
  93. bodyGyro.P = 10000
  94. bodyGyro.MaxTorque = Vector3.new(1e5, 1e5, 1e5)
  95.  
  96. local offsetPos = {
  97.     ["Top"] = Vector3.new(0, 1, 0);
  98.     ["Center"] = Vector3.new(0, 0, 0);
  99.     ["Right"] = Vector3.new(1, 0, 0);
  100.     ["TopLeft"] = Vector3.new(-1, 1, 0);
  101.     ["TopRight"] = Vector3.new(1, 1, 0);
  102.     ["RightBottom"] = Vector3.new(1, -1, 0);
  103.     ["Left"] = Vector3.new(-1, 0, 0);
  104.     ["Bottom"] = Vector3.new(0, -1, 0);
  105.     ["BottomLeft"] = Vector3.new(-1, -1, 0);
  106. }
  107.  
  108. local offsetPos2 = {
  109.     ["Top"] = Vector3.new(0, 1, 0);
  110.     ["Center"] = Vector3.new(0, 0, 0);
  111.     ["Bottom"] = Vector3.new(0, -1, 0)
  112. }
  113.  
  114. function loadAnim(id)
  115.     local animTrack = Instance.new("Animation")
  116.     animTrack.AnimationId = "rbxassetid://" .. id
  117.     return humanoid.Animator:LoadAnimation(animTrack), animTrack:Destroy()
  118. end
  119.  
  120. local BrethCD = false
  121. local IsBreathing = false
  122. local Distance = 1.5
  123. local Distance1 = 0.5
  124. local Speed = 0.3
  125.  
  126. local function StartBreathing()
  127.     IsBreathing = true
  128.     while IsBreathing do
  129.         --print("br")
  130.         RunService.RenderStepped:Wait()
  131.         local yOffset = Distance * math.sin(2 * math.pi * Speed * tick())
  132.         humanoid.CameraOffset = Vector3.new(0, yOffset, 0)
  133.     end
  134. end
  135.  
  136. local function Breath()
  137.     IsBreathing = false
  138.     while IsBreathing == false do
  139.         RunService.RenderStepped:Wait()
  140.         local yOffset = Distance1 * math.sin(2 * math.pi * Speed * tick())
  141.         humanoid.CameraOffset = Vector3.new(0, yOffset, 0)
  142.     end
  143. end
  144.  
  145. local function StopBreathing()
  146.     IsBreathing = false
  147.     humanoid.CameraOffset = Vector3.new(0, 0, 0)
  148.     task.delay(0.5, function()
  149.         TweenService:Create(humanoid, TweenInfo.new(0.75), {CameraOffset = Vector3.new(0, 0, 0)}):Play()
  150.     end)
  151. end
  152.  
  153. function findTool(tool)
  154.     for index,data in pairs(tools) do
  155.         if (data.tool == tool) then
  156.             return tools[index], index
  157.         end
  158.     end
  159.  
  160.     return false
  161. end
  162.  
  163. function destroyed(x)
  164.     if x.Parent then return false end
  165.     local _, result = pcall(function() x.Parent = x end)
  166.     return result:match("locked") and true or false
  167. end
  168.  
  169. Assets.Events.ToolLoader.Event:Connect(function(tool, type, data, unique_id)
  170.     if (not tools[unique_id] and type == "registerGun") then
  171.         tools[unique_id] = {
  172.             tool = tool;
  173.             anims = {};
  174.             gun = true;
  175.             settings = data.settings
  176.         }
  177.  
  178.         for index,data in pairs(data.anims) do
  179.             tools[unique_id].anims[index] = loadAnim(data)
  180.         end
  181.     end
  182.  
  183.     if (tools[unique_id]) then
  184.         if (tools[unique_id].gun) then
  185.             if (not equippingGun) then
  186.                 equipDelay = tick()
  187.             end
  188.             equippingGun = tool:IsDescendantOf(character)
  189.             gunTool = tool
  190.         end
  191.         if (type == "anims") then
  192.             tools[unique_id].anims[data]:Play()
  193.         elseif (type == "stopAnims") then
  194.             for index,anim in pairs(tools[unique_id].anims) do
  195.                 local canStop = true
  196.                 for _,v in pairs(data) do
  197.                     if (v == index) then
  198.                         canStop = false
  199.                         break
  200.                     end
  201.                 end
  202.                 if (canStop) then
  203.                     anim:Stop()
  204.                 end
  205.             end
  206.         end
  207.     end
  208. end)
  209.  
  210. function lerp(a, b, t)
  211.     return a + (b - a) * t
  212. end
  213.  
  214. function debugLine(p1, p2, t, b)
  215.     if (not config.debug and not b) then
  216.         return
  217.     end
  218.  
  219.     local startPoint = Assets.Miscs.rayDebug.start:Clone()
  220.     local endPoint = Assets.Miscs.rayDebug["end"]:Clone()
  221.     startPoint.Position = p1
  222.     endPoint.Position = p2
  223.     startPoint.Parent, endPoint.Parent = workspace.Ignored, workspace.Ignored
  224.     startPoint.Beam.Attachment1 = endPoint.point
  225.     Debris:AddItem(startPoint, t or config.default_debug_clean_time)
  226.     Debris:AddItem(endPoint, t or config.default_debug_clean_time)
  227.     return startPoint, endPoint
  228. end
  229.  
  230. function debugDot(p1, t, b)
  231.     if (not config.debug and not b) then
  232.         return
  233.     end
  234.  
  235.     local dot = Assets.Miscs.dot:Clone()
  236.     dot.Position = p1
  237.     dot.Parent = workspace.Ignored
  238.     Debris:AddItem(dot, t or config.default_debug_clean_time)
  239.     return dot
  240. end
  241.  
  242. function findHumanoid(p)
  243.     if (p.Parent:FindFirstChild("Humanoid")) then
  244.         return p.Parent
  245.     end
  246.  
  247.     if (p.Parent ~= workspace) then
  248.         return findHumanoid(p.Parent)
  249.     end
  250.  
  251.     return false
  252. end
  253.  
  254. function getDistance(p1, p2)
  255.     return ((typeof(p1) == "Instance" and p1.Position or p1) - (typeof(p2) == "Instance" and p2.Position or p2)).magnitude
  256. end
  257.  
  258. function getRandomChild(parent)
  259.     return parent:GetChildren()[math.random(#parent:GetChildren())]
  260. end
  261.  
  262. function playsound(sound, parent, pitch)
  263.     local isPos = typeof(parent) == "Vector3"
  264.     if (isPos) then
  265.         local pos = parent
  266.         parent = Instance.new("Attachment")
  267.         parent.WorldPosition = pos
  268.         parent.Parent = workspace.Terrain
  269.     end
  270.  
  271.     local sound = sound:Clone()
  272.     sound.PlaybackSpeed = pitch and sound.PlaybackSpeed + (math.random() * pitch) or sound.PlaybackSpeed
  273.     sound.Parent = parent
  274.     sound:Play()
  275.     Debris:AddItem(isPos and parent or sound, sound.TimeLength + 1)
  276.     return sound
  277. end
  278.  
  279. local isReloading = false
  280.  
  281. function reloadWeapon(gunData, CurrAmm)
  282.     if isReloading == true then return end
  283.     isReloading = true
  284.     gunData.anims.reload:Play()
  285.     gunData.anims.reload.Stopped:Wait()
  286.     gunData.settings.reload.CurrAmm = gunData.settings.reload.MaxAmm
  287.     gunData.tool:SetAttribute("CurrAmmo", gunData.settings.reload.MaxAmm)
  288.     task.wait(0.25)
  289.     isReloading = false
  290. end
  291.  
  292.  
  293. local function Fireeee(isMobile)
  294.     local gunData, unique_id = findTool(gunTool)
  295.     if (tick() - delay < gunData.settings.rate) then
  296.         return
  297.     end
  298.     gunData.tool:SetAttribute("CurrAmmo", gunData.settings.reload.CurrAmm)
  299.     local function fire()
  300.         if isReloading then return end
  301.         --if gunData.settings.reload.enabled  then
  302.         gunData.settings.reload.CurrAmm = gunData.settings.reload.CurrAmm - 1
  303.         gunData.tool:SetAttribute("CurrAmmo", gunData.settings.reload.CurrAmm)
  304.         --  local CurrAmm = gunData.settings.reload.CurrAmm
  305.         --
  306.         --  if gunData.settings.reload.CurrAmm == 0 then
  307.         --      if CurrAmm ~= gunData.settings.reload.MaxAmm then
  308.         --          reloadWeapon(gunData, CurrAmm)
  309.         --          return
  310.         --      end
  311.         --      return
  312.         --  end
  313.         --end
  314.         lastActive = tick()
  315.         local origin, dir = mouse.UnitRay.Origin, mouse.UnitRay.Direction
  316.  
  317.  
  318.         if isMobile ~= nil then
  319.             local CrossHair = player.PlayerGui:WaitForChild("CrossHair"):WaitForChild("Crosshair")
  320.             local ray = workspace.CurrentCamera:ScreenPointToRay(CrossHair.AbsolutePosition.X, CrossHair.AbsolutePosition.Y)
  321.             origin, dir = ray.Origin, ray.Direction
  322.         end
  323.  
  324.         if (gunData.settings.shotgun.enabled) then
  325.             dir += Vector3.new(
  326.                 math.random(-100, 100) / 5000 * gunData.settings.shotgun.spreadness,
  327.                 math.random(-100, 100) / 5000 * gunData.settings.shotgun.spreadness,
  328.                 math.random(-100, 100) / 5000 * gunData.settings.shotgun.spreadness
  329.             )
  330.         end
  331.  
  332.         dir *= 1e4
  333.         -- // bullet tracer
  334.         local startTracer, endTracer = Assets.Miscs.bulletTracer.start:Clone(), Assets.Miscs.bulletTracer["end"]:Clone()
  335.         local beamTracer = Assets.Miscs.bulletTracer.Beam:Clone()
  336.         local Smoke = Assets.Miscs.bulletTracer.Smoke:Clone()
  337.         Smoke.Parent = startTracer
  338.         beamTracer.Attachment0 = startTracer
  339.         beamTracer.Attachment1 = endTracer
  340.         startTracer.Parent, endTracer.Parent = workspace.Terrain, workspace.Terrain
  341.         beamTracer.Parent = workspace.Terrain
  342.         startTracer.WorldPosition = gunTool.Handle.Muzzle.WorldPosition
  343.         task.delay(2, function()Smoke:Destroy() beamTracer:Destroy()end)
  344.  
  345.         local cast = workspace:Raycast(origin, dir, params)
  346.         if (cast) then
  347.             endTracer.WorldPosition = cast.Position
  348.             local startLine, endLine = debugLine(origin, cast.Position, 1)
  349.             if (startLine) then
  350.                 startLine.Beam.Color = ColorSequence.new(Color3.fromRGB(0, 255, 0))
  351.             end
  352.             local model = findHumanoid(cast.Instance)
  353.             local Players = game:GetService("Players")
  354.  
  355.             if model and not Players:GetPlayerFromCharacter(model) then
  356.                 BombEvent:FireServer(model)
  357.                 return
  358.             end
  359.  
  360.             if (model) and player.Character ~= model and player.Team ~= game.Players:GetPlayerFromCharacter(model).Team then
  361.                 local ignore = {workspace.Ignored, model}
  362.                 local originPos = cast.Position + cast.Normal / 20
  363.  
  364.                 local hitPoint = CFrame.new(originPos, originPos + cast.Normal)
  365.                 local objectSpace = model.Torso.CFrame:toObjectSpace(hitPoint)
  366.                 local lastHealth = model.Humanoid.Health
  367.                 Network:FireServer("hit", model, cast.Instance, cast.Position + dir, objectSpace, gunData.settings)
  368.  
  369.                 local death, damage = false, cast.Instance.Name == "Head" and gunData.settings.damage * gunData.settings.critical or gunData.settings.damage
  370.                 if (model.Humanoid.Health - damage <= 0 and lastHealth > 0 and not model.Head:FindFirstChild("gurgle")) then
  371.                     for _,sound in pairs(model.Head:GetChildren()) do
  372.                         if (sound.Name == "hurt") then
  373.                             sound:Destroy()
  374.                         end
  375.                     end
  376.                     local gurgle
  377.                     while true do
  378.                         gurgle = getRandomChild(Assets.Sounds.gurgles)
  379.                         if (gurgle ~= lastGurgle) then
  380.                             break
  381.                         end
  382.                         task.wait()
  383.                     end
  384.                     lastGurgle = gurgle
  385.                     playsound(gurgle, model.Head, 0.2)
  386.  
  387.                     death = true
  388.                 end
  389.  
  390.                 local damageStreak = model.Humanoid:FindFirstChild("damage_streak")
  391.                 if (not damageStreak) then
  392.                     damageStreak = Instance.new("NumberValue")
  393.                     damageStreak.Name = "damage_streak"
  394.                     damageStreak.Parent = model.Humanoid
  395.                 end
  396.  
  397.                 damageStreak.Value += gunData.settings.damage
  398.                 -- // gibs system
  399.                 local gib, dist = getGibFromPosition(cast.Instance, cast.Position)
  400.                 local Success, Err = pcall(function()
  401.                     gib.Touched:Connect(function(hit)
  402.                         if (gib and (gunData.settings.damage >= 20 or damageStreak.Value >= 30) and gunData.settings.dismember) then
  403.                             -- // head gib
  404.                             if (cast.Instance.Name == "Head") then
  405.                                 if (not cast.Instance:FindFirstChild("GIBS")) then
  406.                                     for _,wound in pairs(cast.Instance:GetChildren()) do
  407.                                         if (wound.Name == "wound") then
  408.                                             wound:Destroy()
  409.                                         end
  410.                                     end
  411.                                     cast.Instance.Transparency = 1
  412.                                     local gibModel = getRandomChild(Assets.Gibs.Head[gib]):Clone()
  413.                                     if (gibModel.Transparency < 1) then
  414.                                         gibModel.Color = cast.Instance.Color
  415.                                     else
  416.                                         for _,skin in pairs(gibModel:GetChildren()) do
  417.                                             if (skin.Name == "Skin") then
  418.                                                 skin.Color = cast.Instance.Color
  419.                                             end
  420.                                         end
  421.                                     end
  422.                                     -- // remove accessories
  423.                                     for _,handle in pairs(model:GetDescendants()) do
  424.                                         if (handle:IsA("Part") and (handle:FindFirstChild("HatAttachment") or handle:FindFirstChild("FaceFrontAttachment") or handle:FindFirstChild("FaceCenterAttachment") or handle:FindFirstChild("HairAttachment"))) then
  425.                                             for _,stuff in pairs(handle:GetChildren()) do
  426.                                                 if (stuff:IsA("Attachment") or stuff:IsA("Weld")) then
  427.                                                     stuff:Destroy()
  428.                                                 end
  429.                                             end
  430.                                             --[[if (not handle:FindFirstChild("HairAttachment")) then
  431.                                                 handle:BreakJoints()
  432.                                                 handle.CanCollide = true
  433.                                                 handle.CollisionGroupId = 3
  434.                                                 local accessory = handle.Parent
  435.                                                 handle.Velocity = dir.unit * math.random(15, 20)
  436.                                                 handle.Parent = workspace.Ignored
  437.                                                 local connection
  438.                                                 connection = model.Destroying:Connect(function()
  439.                                                     connection:Disconnect()
  440.                                                     handle:Destroy()
  441.                                                 end)
  442.                                                 accessory:Destroy()
  443.                                             else
  444.                                                 handle.Parent:Destroy()
  445.                                             end]]
  446.                                             handle.Parent:Destroy()
  447.                                         end
  448.                                     end
  449.                                     --
  450.                                     gibModel.Name = model.Name .. "_" .. gibModel.Name
  451.                                     gibModel.Parent = workspace.Ignored
  452.                                     local gibs = Instance.new("ObjectValue")
  453.                                     gibs.Name = "GIBS"
  454.                                     gibs.Value = gibModel
  455.                                     gibs.Parent = cast.Instance
  456.                                     if (gib ~= "Bottom") then
  457.                                         local weld = Instance.new("Weld")
  458.                                         weld.Part0 = cast.Instance
  459.                                         weld.Part1 = gibModel
  460.                                         weld.Parent = gibModel
  461.                                     else
  462.                                         local neckModel = Assets.Gibs.Neck:Clone()
  463.                                         neckModel.Skin.Color = cast.Instance.Color
  464.                                         neckModel.Parent = gibModel
  465.                                         local neckWeld = Instance.new("Weld")
  466.                                         neckWeld.Part0 = cast.Instance
  467.                                         neckWeld.Part1 = neckModel
  468.                                         neckWeld.Parent = neckModel
  469.                                         cast.Instance.CollisionGroupId = 2
  470.                                         gibModel.CFrame = cast.Instance.CFrame
  471.                                         gibModel.Velocity = dir.unit
  472.                                             * math.random(80, 100)
  473.                                             + Vector3.new(0, math.random(20, 30), 0)
  474.                                         local totalMass = gibModel:GetMass()
  475.                                         for _,part in pairs(gibModel:GetChildren()) do
  476.                                             if (part:IsA("BasePart")) then
  477.                                                 totalMass += part:GetMass()
  478.                                             end
  479.                                         end
  480.                                         local force = Instance.new("BodyForce")
  481.                                         force.Force = Vector3.new(0, totalMass * 120, 0)
  482.                                         force.Parent = gibModel
  483.                                         gibModel.Velocity = getClampedVel(gibModel.Velocity, 50)
  484.                                         task.spawn(function()
  485.                                             local blood_settings = {
  486.                                                 ["spreadness"] = 2,
  487.                                                 ["amount"] = math.random(15, 20),
  488.                                                 ["process"] = {15, 20, 100},
  489.                                                 ["size"] = {60, 150, 100},
  490.                                                 ["tweenIn"] = TweenInfo.new(0.8, Enum.EasingStyle.Quint),
  491.                                                 ["mode"] = "track",
  492.                                                 ["parent"] = neckModel,
  493.                                                 ["drain"] = true,
  494.                                             }
  495.                                             handleBlood(neckModel, cast.Position + (cast.Normal / 100), neckModel.CFrame.UpVector * math.random(150, 200), {model, cast.Instance, workspace.Ignored}, blood_settings)
  496.                                         end)
  497.                                         task.spawn(function()
  498.                                             local blood_settings = {
  499.                                                 ["spreadness"] = 1.1,
  500.                                                 ["amount"] = math.random(4, 6),
  501.                                                 ["process"] = {150, 300, 100},
  502.                                                 ["size"] = {60, 300, 100},
  503.                                                 ["tweenIn"] = TweenInfo.new(5, Enum.EasingStyle.Quint),
  504.                                                 ["mode"] = "track",
  505.                                                 ["parent"] = gibModel,
  506.                                                 ["drain"] = true,
  507.                                             }
  508.                                             handleBlood(gibModel, gibModel.Position, gibModel.CFrame.UpVector * -math.random(5, 10), {model, cast.Instance, workspace.Ignored}, blood_settings)
  509.                                         end)
  510.                                     end
  511.                                     local connection
  512.                                     connection = model.Destroying:Connect(function()
  513.                                         connection:Disconnect()
  514.                                         gibModel:Destroy()
  515.                                     end)
  516.                                     local decal = cast.Instance:FindFirstChildWhichIsA("Decal")
  517.                                     local decal1 = gibModel:FindFirstChildWhichIsA("Decal")
  518.                                     if (decal1 and decal) then
  519.                                         decal1.Texture = decal.Texture
  520.                                         decal:Destroy()
  521.                                     end
  522.                                     local originNormal = character.Head.CFrame.LookVector
  523.                                     local cur = 0
  524.                                     for _,gib in pairs(Assets.Gibs.Debris:GetChildren()) do
  525.                                         local force = originNormal - (2 * originNormal:Dot(cast.Normal) * cast.Normal)
  526.                                         local dir = force * math.random(15, 35) + Vector3.new(0, math.random(5, 15), 0)
  527.                                         local gib = gib:Clone()
  528.                                         gib.CFrame = cast.Instance.CFrame + Vector3.new(math.random(-1, 1) / 10, math.random(-1, 1) / 10, math.random(-1, 1) / 10)
  529.                                         gib.Velocity = dir + Vector3.new(
  530.                                             math.random(-500, 500) / 100,
  531.                                             math.random(-500, 500) / 100,
  532.                                             math.random(-500, 500) / 100
  533.                                         )
  534.                                         gib.RotVelocity = gib.Velocity / 2
  535.                                         gib.Color = cast.Instance.Color
  536.                                         gib.Parent = workspace.Ignored
  537.                                         Debris:AddItem(gib, 0.85)
  538.                                         local force = Instance.new("BodyForce")
  539.                                         force.Force = Vector3.new(0, gib:GetMass() * 100, 0)
  540.                                         force.Parent = gib
  541.                                         cur += 1
  542.                                         if (math.random(3) == 1 and cur > 1) then
  543.                                             break
  544.                                         end
  545.                                     end
  546.                                 else
  547.                                     local gibObject = cast.Instance.GIBS.Value
  548.                                     gibObject:Destroy()
  549.                                     local neckModel = Assets.Gibs.Neck:Clone()
  550.                                     neckModel.Skin.Color = cast.Instance.Color
  551.                                     neckModel.Parent = workspace.Ignored
  552.                                     local neckWeld = Instance.new("Weld")
  553.                                     neckWeld.Part0 = cast.Instance
  554.                                     neckWeld.Part1 = neckModel
  555.                                     neckWeld.Parent = neckModel
  556.                                     cast.Instance.CollisionGroupId = 2
  557.                                     cast.Instance.GIBS.Value = neckModel
  558.                                     task.spawn(function()
  559.                                         local blood_settings = {
  560.                                             ["spreadness"] = 2,
  561.                                             ["amount"] = math.random(15, 20),
  562.                                             ["process"] = {15, 20, 100},
  563.                                             ["size"] = {60, 150, 100},
  564.                                             ["tweenIn"] = TweenInfo.new(0.8, Enum.EasingStyle.Quint),
  565.                                             ["mode"] = "track",
  566.                                             ["parent"] = neckModel,
  567.                                             ["drain"] = true,
  568.                                         }
  569.                                         handleBlood(neckModel, cast.Position + (cast.Normal / 100), neckModel.CFrame.UpVector * math.random(150, 200), {model, cast.Instance, workspace.Ignored}, blood_settings)
  570.                                     end)
  571.  
  572.                                     local connection
  573.                                     connection = model.Destroying:Connect(function()
  574.                                         connection:Disconnect()
  575.                                         neckModel:Destroy()
  576.                                     end)
  577.  
  578.                                     cast.Instance:ClearAllChildren()
  579.                                 end
  580.                             elseif (string.find(cast.Instance.Name, "Arm") or string.find(cast.Instance.Name, "Leg")) then
  581.                                 if (not cast.Instance:FindFirstChild("GIBS")) then
  582.                                     for _,sound in pairs(model.Head:GetChildren()) do
  583.                                         if (sound.Name == "hurt") then
  584.                                             sound:Destroy()
  585.                                         end
  586.                                     end
  587.                                     local sound = playsound(getRandomChild(Assets.Sounds.hurt), model.Head, 0.25)
  588.                                     sound.Name = "hurt"
  589.                                     for _,wound in pairs(cast.Instance:GetChildren()) do
  590.                                         if (wound.Name == "wound") then
  591.                                             wound:Destroy()
  592.                                         end
  593.                                     end
  594.  
  595.                                     cast.Instance.Transparency = 1
  596.                                     local gibModel = getRandomChild(Assets.Gibs.Limbs[gib]):Clone()
  597.                                     for _,skin in pairs(gibModel:GetDescendants()) do
  598.                                         if (skin:IsA("BasePart") and (skin.Name == "Skin" or skin.Name == "Debris")) then
  599.                                             skin.Color = cast.Instance.Color
  600.                                         end
  601.                                     end
  602.                                     local weld = Instance.new("Weld")
  603.                                     weld.Part0 = cast.Instance
  604.                                     weld.Part1 = gibModel.Attach
  605.                                     weld.Parent = gibModel
  606.  
  607.                                     --[[local shirtInstance = model:FindFirstChildWhichIsA("Shirt")
  608.                                     if (shirtInstance and gibModel.Attach:FindFirstChild("Skin")) then
  609.                                         local shirt = Instance.new("SurfaceAppearance")
  610.                                         shirt.Parent = gibModel.Attach.Skin
  611.                                         shirt.ColorMap = shirtInstance.ShirtTemplate
  612.                                     end]]
  613.  
  614.                                     gibModel.Name = model.Name .. "_" .. gibModel.Name
  615.                                     gibModel.Parent = workspace.Ignored
  616.                                     local gibs = Instance.new("ObjectValue")
  617.                                     gibs.Name = "GIBS"
  618.                                     gibs.Value = gibModel
  619.                                     gibs.Parent = cast.Instance
  620.  
  621.                                     local debrisWeld = gibModel.Attach:FindFirstChild("Debris")
  622.                                     if (debrisWeld) then
  623.                                         task.delay(1 / 30, function()
  624.                                             debrisWeld:Destroy()
  625.  
  626.                                             gibModel.Debris.Velocity = (dir.unit * math.random(5, 10)) + Vector3.new(math.random(-100, 100) / 100,math.random(-100, 100) / 100,math.random(-100, 100) / 100)
  627.                                             gibModel.Debris.RotVelocity = gibModel.Debris.Velocity
  628.                                             local force = Instance.new("BodyForce")
  629.                                             force.Force = Vector3.new(0, gibModel.Debris:GetMass() * 120, 0)
  630.                                             force.Parent = gibModel.Debris
  631.                                         end)
  632.                                     end
  633.  
  634.                                     task.spawn(function()
  635.                                         local blood_settings = {
  636.                                             ["spreadness"] = 2,
  637.                                             ["amount"] = math.random(15, 20),
  638.                                             ["process"] = {15, 20, 100},
  639.                                             ["size"] = {60, 150, 100},
  640.                                             ["tweenIn"] = TweenInfo.new(0.8, Enum.EasingStyle.Quint),
  641.                                             ["mode"] = "track",
  642.                                             ["parent"] = gibModel.Attach,
  643.                                             ["drain"] = true,
  644.                                             ["meat"] = true,
  645.                                             ["meatAmount"] = math.random(6, 8)
  646.                                         }
  647.                                         handleBlood(gibModel.Attach, cast.Position + (cast.Normal / 100), dir.unit * math.random(20, 30), {model, cast.Instance, workspace.Ignored}, blood_settings)
  648.                                     end)
  649.  
  650.                                     if (gibModel:FindFirstChild("Debris")) then
  651.                                         task.spawn(function()
  652.                                             local blood_settings = {
  653.                                                 ["spreadness"] = 2,
  654.                                                 ["amount"] = math.random(8, 12),
  655.                                                 ["process"] = {45, 50, 100},
  656.                                                 ["size"] = {60, 240, 100},
  657.                                                 ["tweenIn"] = TweenInfo.new(0.8, Enum.EasingStyle.Quint),
  658.                                                 ["mode"] = "track",
  659.                                                 ["parent"] = gibModel.Debris,
  660.                                                 ["drain"] = true,
  661.                                             }
  662.                                             handleBlood(gibModel.Debris, cast.Position + (cast.Normal / 100), gibModel.Debris.CFrame.UpVector * -5, {model, cast.Instance, workspace.Ignored}, blood_settings)
  663.                                         end)
  664.                                     end
  665.  
  666.                                     local connection
  667.                                     connection = model.Destroying:Connect(function()
  668.                                         connection:Disconnect()
  669.                                         gibModel:Destroy()
  670.                                     end)
  671.  
  672.                                     local originNormal = character.Head.CFrame.LookVector
  673.                                     local cur = 0
  674.                                     for _,gib in pairs(Assets.Gibs.Debris:GetChildren()) do
  675.                                         local force = originNormal - (2 * originNormal:Dot(cast.Normal) * cast.Normal)
  676.                                         local dir = force * math.random(15, 35) + Vector3.new(0, math.random(5, 15), 0)
  677.                                         local gib = gib:Clone()
  678.                                         gib.CFrame = cast.Instance.CFrame + Vector3.new(math.random(-1, 1) / 10, math.random(-1, 1) / 10, math.random(-1, 1) / 10)
  679.                                         gib.Velocity = dir + Vector3.new(
  680.                                             math.random(-500, 500) / 100,
  681.                                             math.random(-500, 500) / 100,
  682.                                             math.random(-500, 500) / 100
  683.                                         )
  684.                                         gib.RotVelocity = gib.Velocity / 2
  685.                                         gib.Color = cast.Instance.Color
  686.                                         gib.Parent = workspace.Ignored
  687.                                         Debris:AddItem(gib, 0.85)
  688.                                         local force = Instance.new("BodyForce")
  689.                                         force.Force = Vector3.new(0, gib:GetMass() * 100, 0)
  690.                                         force.Parent = gib
  691.                                         cur += 1
  692.                                         if (math.random(3) == 1 and cur > 1) then
  693.                                             break
  694.                                         end
  695.                                     end
  696.                                 else
  697.  
  698.                                 end
  699.                             end
  700.                         end
  701.                         --
  702.                     end)
  703.                 end)
  704.                 playsound(getRandomChild(Assets.Sounds.bullet_flesh), cast.Position, 0.5)
  705.                 if (not cast.Instance:FindFirstChild("GIBS")) then
  706.                     -- // blood and wounds
  707.                     handleWound(cast, model, originPos)
  708.                     --
  709.  
  710.                     -- // exit wound
  711.                     do
  712.                         local params = RaycastParams.new()
  713.                         params.FilterDescendantsInstances = {model}
  714.                         params.FilterType = Enum.RaycastFilterType.Include
  715.                         params.CollisionGroup = "Raycast"
  716.                         local origin, dir1 = cast.Position + dir.unit * getSize(cast.Instance), dir.unit * -dir.magnitude
  717.                         local cast = workspace:Raycast(origin, dir1, params)
  718.                         local startLine, endLine
  719.                         if (cast) then
  720.                             startLine, endLine = debugLine(origin, cast.Position)
  721.                             if (startLine) then
  722.                                 startLine.Beam.Color = ColorSequence.new(Color3.fromRGB(0, 255, 0))
  723.                             end
  724.                             handleWound(cast, model, cast.Position + cast.Normal / 20)
  725.                             local blood_settings = {
  726.                                 ["spreadness"] = 2,
  727.                                 ["amount"] = math.random(10, 12),
  728.                                 ["process"] = {10, 15, 100},
  729.                                 ["size"] = {50, 140, 100},
  730.                                 ["mode"] = "track",
  731.                                 ["parent"] = cast.Instance,
  732.                                 ["tweenIn"] = TweenInfo.new(0.5, Enum.EasingStyle.Sine),
  733.                                 ["drain"] = true,
  734.                             }
  735.                             task.spawn(function()
  736.                                 handleBlood(model, cast.Position + cast.Normal / 20, dir.unit * 50, ignore, blood_settings)
  737.                             end)
  738.                         else
  739.                             startLine, endLine = debugLine(origin, dir1)
  740.                         end
  741.                     end
  742.                     --
  743.                 end
  744.  
  745.                 -- // reflect blood
  746.                 if (math.random(5) == 1 or death) then
  747.                     task.spawn(function()
  748.                         local originNormal = character.Head.CFrame.LookVector
  749.                         -- // ray reflection
  750.                         local force = originNormal - (2 * originNormal:Dot(cast.Normal) * cast.Normal)
  751.                         local dir = force * math.random(15, 20) + Vector3.new(0, math.random(5, 10), 0)
  752.                         local amount = (gunData.settings.shotgun.enabled and gunData.settings.damage / gunData.settings.shotgun.amount or gunData.settings.damage) * 3.5
  753.                         local blood_settings = {
  754.                             ["spreadness"] = 2,
  755.                             ["amount"] = math.random(amount / 2, amount),
  756.                             ["process"] = {10, 15, 100},
  757.                             ["size"] = {15, 40, 100},
  758.                             ["mode"] = "track",
  759.                             ["parent"] = cast.Instance.Name == "HumanoidRootPart" and cast.Instance.Parent.Torso or cast.Instance,
  760.                             ["tweenIn"] = TweenInfo.new(0.25, Enum.EasingStyle.Quint),
  761.                             ["drain"] = true;
  762.                         }
  763.                         handleBlood(model, cast.Position, dir, ignore, blood_settings)
  764.                     end)
  765.                 end
  766.                 ---
  767.  
  768.                 -- // reflect fast blood
  769.                 task.spawn(function()
  770.                     local originNormal = character.Head.CFrame.LookVector
  771.                     -- // ray reflection
  772.                     local force = originNormal - (2 * originNormal:Dot(cast.Normal) * cast.Normal)
  773.                     local dir = force * math.random(10, 15) + Vector3.new(0, math.random(5), 0)
  774.                     local amount = (gunData.settings.shotgun.enabled and gunData.settings.damage / gunData.settings.shotgun.amount or gunData.settings.damage) / 5
  775.                     local blood_settings = {
  776.                         ["spreadness"] = 30,
  777.                         ["amount"] = math.random(amount / 2, amount),
  778.                         ["process"] = {1, 2, 500},
  779.                         ["size"] = {15, 40, 100},
  780.                         ["mode"] = "track",
  781.                         ["parent"] = cast.Instance.Name == "HumanoidRootPart" and cast.Instance.Parent.Torso or cast.Instance,
  782.                         ["tweenIn"] = TweenInfo.new(0.25, Enum.EasingStyle.Quint),
  783.                     }
  784.                     handleBlood(model, cast.Position, dir, ignore, blood_settings)
  785.                 end)
  786.                 ---
  787.  
  788.                 -- // piercing blood
  789.                 local amount = (gunData.settings.shotgun.enabled and gunData.settings.damage / gunData.settings.shotgun.amount or gunData.settings.damage) / 2
  790.                 local blood_settings = {
  791.                     ["spreadness"] = 3,
  792.                     ["amount"] = math.random(amount / 2, amount),
  793.                     ["process"] = {1, 2, 500},
  794.                     ["size"] = {15, 80, 100},
  795.                     ["tweenIn"] = TweenInfo.new(0.05, Enum.EasingStyle.Quint),
  796.                     ["singleSegment"] = true;
  797.                     ["meat"] = cast.Instance.Name == "Head",
  798.                     ["meatAmount"] = math.random(amount / 2, amount),
  799.                 }
  800.                 handleBlood(model, cast.Position, mouse.UnitRay.Direction * 50, ignore, blood_settings)
  801.                 ---
  802.             else
  803.                 local bulletHole = Assets.Bloods.bulletHole:Clone()
  804.                 local size = math.random(25, 30) / 100
  805.                 bulletHole.Size = Vector3.new(size, 0, size)
  806.                 bulletHole.CFrame = CFrame.new(cast.Position, cast.Position + cast.Normal) * CFrame.Angles(math.rad(-90), math.rad(math.random(-90, 90)), 0)
  807.                 bulletHole.Parent = cast.Instance
  808.                 local weld = Instance.new("WeldConstraint")
  809.                 weld.Part0 = cast.Instance.Name == "HumanoidRootPart" and cast.Instance.Parent.Torso or cast.Instance
  810.                 weld.Part1 = bulletHole
  811.                 weld.Parent = bulletHole
  812.                 Debris:AddItem(bulletHole, config.decal_cleanup_time)
  813.                 task.delay(config.decal_cleanup_time - 0.5, function()
  814.                     pcall(function()
  815.                         TweenService:Create(bulletHole.Decal, TweenInfo.new(0.5, Enum.EasingStyle.Sine), {Transparency = 1}):Play()
  816.                     end)
  817.                 end)
  818.             end
  819.  
  820.         else
  821.             debugLine(origin, origin + dir, 1)
  822.             endTracer.WorldPosition = origin + dir
  823.         end
  824.  
  825.         -- // beam transparency tween
  826.         local current = 0.9
  827.         local connection
  828.         connection = RunService.RenderStepped:Connect(function(dt)
  829.             dt *= 60
  830.  
  831.             if (current >= 1 or not beamTracer:IsDescendantOf(workspace)) then
  832.                 connection:Disconnect()
  833.                 return
  834.             end
  835.  
  836.             current = lerp(current, 1, 0.05 * dt)
  837.             beamTracer.Transparency = NumberSequence.new(current)
  838.         end)
  839.  
  840.         Debris:AddItem(startTracer, 1.5)
  841.         Debris:AddItem(endTracer, 1.5)
  842.         Debris:AddItem(beamTracer, 1.5)
  843.     end
  844.     --while gunData.settings.reload.CurrAmm <=0 do
  845.     --  reloadWeapon(gunData)
  846.     --  return
  847.     --end
  848.     while UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) or isMobile == 1 do
  849.         if gunData.settings.reload.CurrAmm <= 0 then
  850.             reloadWeapon(gunData)
  851.             break
  852.         else
  853.             task.wait()
  854.             if isReloading then task.wait() continue end
  855.             if (tick() - delay >= gunData.settings.rate and tick() - equipDelay >= gunData.settings.equip_time) then
  856.                 delay = tick()
  857.                 Assets.Events.ToolLoader:Fire(gunTool, "stopAnims", {"idle"}, unique_id)
  858.                 Assets.Events.ToolLoader:Fire(gunTool, "anims", "fire", unique_id)
  859.                 local recoil = Vector3.new(
  860.                     math.random(gunData.settings.recoil.x[1], gunData.settings.recoil.x[2]),
  861.                     math.random(gunData.settings.recoil.y[1], gunData.settings.recoil.y[2]),
  862.                     math.random(gunData.settings.recoil.z[1], gunData.settings.recoil.z[2])
  863.                 )
  864.                 springCam.Speed = gunData.settings.recoil_speed
  865.                 springCam.Damper = gunData.settings.recoil_damp
  866.                 springCam:Impulse(recoil)
  867.                 task.delay(1 / 15, function()
  868.                     springCam.Speed = gunData.settings.recoil_speed * gunData.settings.recoil_back_threshold
  869.                     springCam.Damper = gunData.settings.recoil_damp / gunData.settings.recoil_back_threshold
  870.                     springCam:Impulse(-recoil / gunData.settings.recoil_back)
  871.                 end)
  872.  
  873.                 playsound(getRandomChild(gunTool.Sounds.Fire), gunTool.Handle.Muzzle, 0.4)
  874.                 playsound(gunTool.Sounds.Echo, gunTool.Handle.Muzzle, 0.6)
  875.                 for _,instance in pairs(gunTool.Handle.Muzzle:GetChildren()) do
  876.                     if (instance:IsA("ParticleEmitter")) then
  877.                         instance:Emit(instance.Rate)
  878.                     elseif (instance.Name == "FlashLight") then
  879.                         local newInstance = instance:Clone()
  880.                         newInstance.Name = ""
  881.                         newInstance.Enabled = true
  882.                         newInstance.Parent = gunTool.Handle.Muzzle
  883.                         Debris:AddItem(newInstance, 1 / 40)
  884.                     end
  885.                 end
  886.  
  887.                 if (gunData.settings.shotgun.enabled) then
  888.                     for k = 1, gunData.settings.shotgun.amount do
  889.                         isMobile = 0
  890.                         task.spawn(fire)
  891.                     end
  892.                 else
  893.                     isMobile = 0
  894.                     task.spawn(fire)
  895.                 end
  896.  
  897.  
  898.                 if (not gunData.settings.auto) then
  899.                     break
  900.                 end
  901.             end
  902.  
  903.             task.wait()
  904.         end
  905.     end
  906. end
  907.  
  908. UserInputService.InputBegan:Connect(function(input, typing)
  909.     if (not typing) then
  910.         if (input.UserInputType == Enum.UserInputType.MouseButton1 and character:FindFirstChild("Head") and equippingGun and gunTool) then
  911.  
  912.             Fireeee()
  913.         elseif (input.UserInputType ~= Enum.UserInputType.MouseButton1 and character:FindFirstChild("Head") and equippingGun and gunTool) then
  914.             local gunData, unique_id = findTool(gunTool)
  915.             if (tick() - delay < gunData.settings.rate) then
  916.                 return
  917.             end
  918.             gunData.tool:SetAttribute("CurrAmmo", gunData.settings.reload.CurrAmm)
  919.         end
  920.     end
  921. end)
  922.  
  923. UserInputService.InputBegan:Connect(function(key)
  924.     if key.UserInputType == Enum.UserInputType.Gamepad1 then
  925.  
  926.         if key.KeyCode == Enum.KeyCode.ButtonR2 and character:FindFirstChild("Head") and equippingGun and gunTool then
  927.             Fireeee(1)
  928.         --  print("firing")
  929.         elseif (key.KeyCode == Enum.KeyCode.Z and character:FindFirstChild("Head") and equippingGun and gunTool) then
  930.             local gunData, unique_id = findTool(gunTool)
  931.             if (tick() - delay < gunData.settings.rate) then
  932.                 return
  933.             end
  934.             gunData.tool:SetAttribute("CurrAmmo", gunData.settings.reload.CurrAmm)
  935.         end
  936.  
  937.  
  938.     end
  939. end)
  940.  
  941. task.spawn(function()
  942.     while humanoid.Health > 0 and humanoid.RootPart and humanoid:IsDescendantOf(workspace) do
  943.         for index,data in pairs(bloodParts) do
  944.             if (data.part and data.placed) then
  945.                 if (getDistance(data.part, camera.CFrame.Position) > config.blood_render_distance) then
  946.                     data.part.Parent = nil
  947.                 elseif (not destroyed(data.part)) then
  948.                     data.part.Parent = workspace.Ignored
  949.                 end
  950.             end
  951.         end
  952.  
  953.         for index,data in pairs(woundParts) do
  954.             if (woundParts[index]) then
  955.                 for _,part in pairs(data) do
  956.                     if (getDistance(part, camera.CFrame.Position) > config.wound_render_distance) then
  957.                         part.Parent = nil
  958.                     elseif (not destroyed(part)) then
  959.                         part.Parent = workspace.Ignored
  960.                     end
  961.                 end
  962.             end
  963.         end
  964.  
  965.         for index,data in pairs(meatParts) do
  966.             if (meatParts[index]) then
  967.                 if (getDistance(meatParts[index], camera.CFrame.Position) > config.meat_render_distance) then
  968.                     meatParts[index].Parent = nil
  969.                 elseif (not destroyed(meatParts[index])) then
  970.                     meatParts[index].Parent = workspace.Ignored
  971.                 end
  972.             end
  973.         end
  974.  
  975.         task.wait(config.render_process)
  976.     end
  977. end)
  978.  
  979.  
Advertisement
Add Comment
Please, Sign In to add comment