Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local UserInputService = game:GetService("UserInputService")
- local Assets = ReplicatedStorage:WaitForChild("Assets")
- local TweenService = game:GetService("TweenService")
- local RunService = game:GetService("RunService")
- local Lighting = game:GetService("Lighting")
- local Players = game:GetService("Players")
- local Debris = game:GetService("Debris")
- local LocalNetwork = ReplicatedStorage:WaitForChild("LocalNetwork")
- local CheckEvent = LocalNetwork:WaitForChild("CheckStats")
- local BombEvent = LocalNetwork:WaitForChild("BombSIgnal")
- local WinsEvent = LocalNetwork:WaitForChild("Wins")
- local OwnLungs = CheckEvent:InvokeServer(714321297)
- local player = Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local mouse = player:GetMouse()
- local camera = workspace.CurrentCamera
- local scopeActivated = false
- local playerGui = player:WaitForChild("PlayerGui")
- local scopeGui = playerGui:WaitForChild("ScopeGUI")["Scope" .. player:WaitForChild("CNFG"):WaitForChild("Scope").Value]
- local FireBTN = player.PlayerGui:WaitForChild("Phone"):WaitForChild("Frame"):WaitForChild("FireBTN")
- local LungsBTN = player.PlayerGui:WaitForChild("Phone"):WaitForChild("Frame"):WaitForChild("LungsBTN")
- local Spring = require(Assets.Modules.Spring)
- local Network = require(Assets.Modules.Network)
- local humanoid = character:WaitForChild("Humanoid")
- local neck = character.Torso:WaitForChild("Neck")
- local defaultNeck = neck.C0
- local lastGurgle
- local rightShoulder, leftShoulder = character.Torso:WaitForChild("Right Shoulder"), character.Torso:WaitForChild("Left Shoulder")
- local config = {
- blood_timeout = 2;
- meat_timeout = 2;
- blood_cleanup_time = 5;
- blood_cleanup_animation_time = 2.5;
- max_blood_parts = 1000;
- max_wound_parts = 20;
- max_meat_parts = 80;
- blood_render_distance = 150065;
- wound_render_distance = 60;
- meat_render_distance = 40;
- render_process = 1 / 30;
- decal_cleanup_time = 10;
- meat_cleanup_time = 5;
- combat_time = 1;
- default_debug_clean_time = 5;
- debug = false;
- }
- local springCam = Spring.new(Vector3.new())
- springCam.Speed = 1
- springCam.Damper = 0
- local lastActive = 0
- local delay = 0
- local equipDelay = 0
- local neckTilt = 0
- local aimFOV = 0
- local cameraOffset = 1.5
- local DOFPos = Vector3.new()
- local default_sens = UserInputService.MouseDeltaSensitivity
- local bloodParts = {}
- local woundParts = {}
- local meatParts = {}
- local tools = {}
- local equippingGun = false
- local gunTool
- local params = RaycastParams.new()
- params.FilterDescendantsInstances = {workspace.Ignored, workspace.Characters}
- params.IgnoreWater = true
- params.CollisionGroup = "Raycast"
- params.FilterDescendantsInstances = {character}
- local bodyGyro = Instance.new("BodyGyro")
- bodyGyro.D = 250
- bodyGyro.P = 10000
- bodyGyro.MaxTorque = Vector3.new(1e5, 1e5, 1e5)
- local offsetPos = {
- ["Top"] = Vector3.new(0, 1, 0);
- ["Center"] = Vector3.new(0, 0, 0);
- ["Right"] = Vector3.new(1, 0, 0);
- ["TopLeft"] = Vector3.new(-1, 1, 0);
- ["TopRight"] = Vector3.new(1, 1, 0);
- ["RightBottom"] = Vector3.new(1, -1, 0);
- ["Left"] = Vector3.new(-1, 0, 0);
- ["Bottom"] = Vector3.new(0, -1, 0);
- ["BottomLeft"] = Vector3.new(-1, -1, 0);
- }
- local offsetPos2 = {
- ["Top"] = Vector3.new(0, 1, 0);
- ["Center"] = Vector3.new(0, 0, 0);
- ["Bottom"] = Vector3.new(0, -1, 0)
- }
- function loadAnim(id)
- local animTrack = Instance.new("Animation")
- animTrack.AnimationId = "rbxassetid://" .. id
- return humanoid.Animator:LoadAnimation(animTrack), animTrack:Destroy()
- end
- local BrethCD = false
- local IsBreathing = false
- local Distance = 1.5
- local Distance1 = 0.5
- local Speed = 0.3
- local function StartBreathing()
- IsBreathing = true
- while IsBreathing do
- --print("br")
- RunService.RenderStepped:Wait()
- local yOffset = Distance * math.sin(2 * math.pi * Speed * tick())
- humanoid.CameraOffset = Vector3.new(0, yOffset, 0)
- end
- end
- local function Breath()
- IsBreathing = false
- while IsBreathing == false do
- RunService.RenderStepped:Wait()
- local yOffset = Distance1 * math.sin(2 * math.pi * Speed * tick())
- humanoid.CameraOffset = Vector3.new(0, yOffset, 0)
- end
- end
- local function StopBreathing()
- IsBreathing = false
- humanoid.CameraOffset = Vector3.new(0, 0, 0)
- task.delay(0.5, function()
- TweenService:Create(humanoid, TweenInfo.new(0.75), {CameraOffset = Vector3.new(0, 0, 0)}):Play()
- end)
- end
- function findTool(tool)
- for index,data in pairs(tools) do
- if (data.tool == tool) then
- return tools[index], index
- end
- end
- return false
- end
- function destroyed(x)
- if x.Parent then return false end
- local _, result = pcall(function() x.Parent = x end)
- return result:match("locked") and true or false
- end
- Assets.Events.ToolLoader.Event:Connect(function(tool, type, data, unique_id)
- if (not tools[unique_id] and type == "registerGun") then
- tools[unique_id] = {
- tool = tool;
- anims = {};
- gun = true;
- settings = data.settings
- }
- for index,data in pairs(data.anims) do
- tools[unique_id].anims[index] = loadAnim(data)
- end
- end
- if (tools[unique_id]) then
- if (tools[unique_id].gun) then
- if (not equippingGun) then
- equipDelay = tick()
- end
- equippingGun = tool:IsDescendantOf(character)
- gunTool = tool
- end
- if (type == "anims") then
- tools[unique_id].anims[data]:Play()
- elseif (type == "stopAnims") then
- for index,anim in pairs(tools[unique_id].anims) do
- local canStop = true
- for _,v in pairs(data) do
- if (v == index) then
- canStop = false
- break
- end
- end
- if (canStop) then
- anim:Stop()
- end
- end
- end
- end
- end)
- function lerp(a, b, t)
- return a + (b - a) * t
- end
- function debugLine(p1, p2, t, b)
- if (not config.debug and not b) then
- return
- end
- local startPoint = Assets.Miscs.rayDebug.start:Clone()
- local endPoint = Assets.Miscs.rayDebug["end"]:Clone()
- startPoint.Position = p1
- endPoint.Position = p2
- startPoint.Parent, endPoint.Parent = workspace.Ignored, workspace.Ignored
- startPoint.Beam.Attachment1 = endPoint.point
- Debris:AddItem(startPoint, t or config.default_debug_clean_time)
- Debris:AddItem(endPoint, t or config.default_debug_clean_time)
- return startPoint, endPoint
- end
- function debugDot(p1, t, b)
- if (not config.debug and not b) then
- return
- end
- local dot = Assets.Miscs.dot:Clone()
- dot.Position = p1
- dot.Parent = workspace.Ignored
- Debris:AddItem(dot, t or config.default_debug_clean_time)
- return dot
- end
- function findHumanoid(p)
- if (p.Parent:FindFirstChild("Humanoid")) then
- return p.Parent
- end
- if (p.Parent ~= workspace) then
- return findHumanoid(p.Parent)
- end
- return false
- end
- function getDistance(p1, p2)
- return ((typeof(p1) == "Instance" and p1.Position or p1) - (typeof(p2) == "Instance" and p2.Position or p2)).magnitude
- end
- function getRandomChild(parent)
- return parent:GetChildren()[math.random(#parent:GetChildren())]
- end
- function playsound(sound, parent, pitch)
- local isPos = typeof(parent) == "Vector3"
- if (isPos) then
- local pos = parent
- parent = Instance.new("Attachment")
- parent.WorldPosition = pos
- parent.Parent = workspace.Terrain
- end
- local sound = sound:Clone()
- sound.PlaybackSpeed = pitch and sound.PlaybackSpeed + (math.random() * pitch) or sound.PlaybackSpeed
- sound.Parent = parent
- sound:Play()
- Debris:AddItem(isPos and parent or sound, sound.TimeLength + 1)
- return sound
- end
- local isReloading = false
- function reloadWeapon(gunData, CurrAmm)
- if isReloading == true then return end
- isReloading = true
- gunData.anims.reload:Play()
- gunData.anims.reload.Stopped:Wait()
- gunData.settings.reload.CurrAmm = gunData.settings.reload.MaxAmm
- gunData.tool:SetAttribute("CurrAmmo", gunData.settings.reload.MaxAmm)
- task.wait(0.25)
- isReloading = false
- end
- local function Fireeee(isMobile)
- local gunData, unique_id = findTool(gunTool)
- if (tick() - delay < gunData.settings.rate) then
- return
- end
- gunData.tool:SetAttribute("CurrAmmo", gunData.settings.reload.CurrAmm)
- local function fire()
- if isReloading then return end
- --if gunData.settings.reload.enabled then
- gunData.settings.reload.CurrAmm = gunData.settings.reload.CurrAmm - 1
- gunData.tool:SetAttribute("CurrAmmo", gunData.settings.reload.CurrAmm)
- -- local CurrAmm = gunData.settings.reload.CurrAmm
- --
- -- if gunData.settings.reload.CurrAmm == 0 then
- -- if CurrAmm ~= gunData.settings.reload.MaxAmm then
- -- reloadWeapon(gunData, CurrAmm)
- -- return
- -- end
- -- return
- -- end
- --end
- lastActive = tick()
- local origin, dir = mouse.UnitRay.Origin, mouse.UnitRay.Direction
- if isMobile ~= nil then
- local CrossHair = player.PlayerGui:WaitForChild("CrossHair"):WaitForChild("Crosshair")
- local ray = workspace.CurrentCamera:ScreenPointToRay(CrossHair.AbsolutePosition.X, CrossHair.AbsolutePosition.Y)
- origin, dir = ray.Origin, ray.Direction
- end
- if (gunData.settings.shotgun.enabled) then
- dir += Vector3.new(
- math.random(-100, 100) / 5000 * gunData.settings.shotgun.spreadness,
- math.random(-100, 100) / 5000 * gunData.settings.shotgun.spreadness,
- math.random(-100, 100) / 5000 * gunData.settings.shotgun.spreadness
- )
- end
- dir *= 1e4
- -- // bullet tracer
- local startTracer, endTracer = Assets.Miscs.bulletTracer.start:Clone(), Assets.Miscs.bulletTracer["end"]:Clone()
- local beamTracer = Assets.Miscs.bulletTracer.Beam:Clone()
- local Smoke = Assets.Miscs.bulletTracer.Smoke:Clone()
- Smoke.Parent = startTracer
- beamTracer.Attachment0 = startTracer
- beamTracer.Attachment1 = endTracer
- startTracer.Parent, endTracer.Parent = workspace.Terrain, workspace.Terrain
- beamTracer.Parent = workspace.Terrain
- startTracer.WorldPosition = gunTool.Handle.Muzzle.WorldPosition
- task.delay(2, function()Smoke:Destroy() beamTracer:Destroy()end)
- local cast = workspace:Raycast(origin, dir, params)
- if (cast) then
- endTracer.WorldPosition = cast.Position
- local startLine, endLine = debugLine(origin, cast.Position, 1)
- if (startLine) then
- startLine.Beam.Color = ColorSequence.new(Color3.fromRGB(0, 255, 0))
- end
- local model = findHumanoid(cast.Instance)
- local Players = game:GetService("Players")
- if model and not Players:GetPlayerFromCharacter(model) then
- BombEvent:FireServer(model)
- return
- end
- if (model) and player.Character ~= model and player.Team ~= game.Players:GetPlayerFromCharacter(model).Team then
- local ignore = {workspace.Ignored, model}
- local originPos = cast.Position + cast.Normal / 20
- local hitPoint = CFrame.new(originPos, originPos + cast.Normal)
- local objectSpace = model.Torso.CFrame:toObjectSpace(hitPoint)
- local lastHealth = model.Humanoid.Health
- Network:FireServer("hit", model, cast.Instance, cast.Position + dir, objectSpace, gunData.settings)
- local death, damage = false, cast.Instance.Name == "Head" and gunData.settings.damage * gunData.settings.critical or gunData.settings.damage
- if (model.Humanoid.Health - damage <= 0 and lastHealth > 0 and not model.Head:FindFirstChild("gurgle")) then
- for _,sound in pairs(model.Head:GetChildren()) do
- if (sound.Name == "hurt") then
- sound:Destroy()
- end
- end
- local gurgle
- while true do
- gurgle = getRandomChild(Assets.Sounds.gurgles)
- if (gurgle ~= lastGurgle) then
- break
- end
- task.wait()
- end
- lastGurgle = gurgle
- playsound(gurgle, model.Head, 0.2)
- death = true
- end
- local damageStreak = model.Humanoid:FindFirstChild("damage_streak")
- if (not damageStreak) then
- damageStreak = Instance.new("NumberValue")
- damageStreak.Name = "damage_streak"
- damageStreak.Parent = model.Humanoid
- end
- damageStreak.Value += gunData.settings.damage
- -- // gibs system
- local gib, dist = getGibFromPosition(cast.Instance, cast.Position)
- local Success, Err = pcall(function()
- gib.Touched:Connect(function(hit)
- if (gib and (gunData.settings.damage >= 20 or damageStreak.Value >= 30) and gunData.settings.dismember) then
- -- // head gib
- if (cast.Instance.Name == "Head") then
- if (not cast.Instance:FindFirstChild("GIBS")) then
- for _,wound in pairs(cast.Instance:GetChildren()) do
- if (wound.Name == "wound") then
- wound:Destroy()
- end
- end
- cast.Instance.Transparency = 1
- local gibModel = getRandomChild(Assets.Gibs.Head[gib]):Clone()
- if (gibModel.Transparency < 1) then
- gibModel.Color = cast.Instance.Color
- else
- for _,skin in pairs(gibModel:GetChildren()) do
- if (skin.Name == "Skin") then
- skin.Color = cast.Instance.Color
- end
- end
- end
- -- // remove accessories
- for _,handle in pairs(model:GetDescendants()) do
- if (handle:IsA("Part") and (handle:FindFirstChild("HatAttachment") or handle:FindFirstChild("FaceFrontAttachment") or handle:FindFirstChild("FaceCenterAttachment") or handle:FindFirstChild("HairAttachment"))) then
- for _,stuff in pairs(handle:GetChildren()) do
- if (stuff:IsA("Attachment") or stuff:IsA("Weld")) then
- stuff:Destroy()
- end
- end
- --[[if (not handle:FindFirstChild("HairAttachment")) then
- handle:BreakJoints()
- handle.CanCollide = true
- handle.CollisionGroupId = 3
- local accessory = handle.Parent
- handle.Velocity = dir.unit * math.random(15, 20)
- handle.Parent = workspace.Ignored
- local connection
- connection = model.Destroying:Connect(function()
- connection:Disconnect()
- handle:Destroy()
- end)
- accessory:Destroy()
- else
- handle.Parent:Destroy()
- end]]
- handle.Parent:Destroy()
- end
- end
- --
- gibModel.Name = model.Name .. "_" .. gibModel.Name
- gibModel.Parent = workspace.Ignored
- local gibs = Instance.new("ObjectValue")
- gibs.Name = "GIBS"
- gibs.Value = gibModel
- gibs.Parent = cast.Instance
- if (gib ~= "Bottom") then
- local weld = Instance.new("Weld")
- weld.Part0 = cast.Instance
- weld.Part1 = gibModel
- weld.Parent = gibModel
- else
- local neckModel = Assets.Gibs.Neck:Clone()
- neckModel.Skin.Color = cast.Instance.Color
- neckModel.Parent = gibModel
- local neckWeld = Instance.new("Weld")
- neckWeld.Part0 = cast.Instance
- neckWeld.Part1 = neckModel
- neckWeld.Parent = neckModel
- cast.Instance.CollisionGroupId = 2
- gibModel.CFrame = cast.Instance.CFrame
- gibModel.Velocity = dir.unit
- * math.random(80, 100)
- + Vector3.new(0, math.random(20, 30), 0)
- local totalMass = gibModel:GetMass()
- for _,part in pairs(gibModel:GetChildren()) do
- if (part:IsA("BasePart")) then
- totalMass += part:GetMass()
- end
- end
- local force = Instance.new("BodyForce")
- force.Force = Vector3.new(0, totalMass * 120, 0)
- force.Parent = gibModel
- gibModel.Velocity = getClampedVel(gibModel.Velocity, 50)
- task.spawn(function()
- local blood_settings = {
- ["spreadness"] = 2,
- ["amount"] = math.random(15, 20),
- ["process"] = {15, 20, 100},
- ["size"] = {60, 150, 100},
- ["tweenIn"] = TweenInfo.new(0.8, Enum.EasingStyle.Quint),
- ["mode"] = "track",
- ["parent"] = neckModel,
- ["drain"] = true,
- }
- handleBlood(neckModel, cast.Position + (cast.Normal / 100), neckModel.CFrame.UpVector * math.random(150, 200), {model, cast.Instance, workspace.Ignored}, blood_settings)
- end)
- task.spawn(function()
- local blood_settings = {
- ["spreadness"] = 1.1,
- ["amount"] = math.random(4, 6),
- ["process"] = {150, 300, 100},
- ["size"] = {60, 300, 100},
- ["tweenIn"] = TweenInfo.new(5, Enum.EasingStyle.Quint),
- ["mode"] = "track",
- ["parent"] = gibModel,
- ["drain"] = true,
- }
- handleBlood(gibModel, gibModel.Position, gibModel.CFrame.UpVector * -math.random(5, 10), {model, cast.Instance, workspace.Ignored}, blood_settings)
- end)
- end
- local connection
- connection = model.Destroying:Connect(function()
- connection:Disconnect()
- gibModel:Destroy()
- end)
- local decal = cast.Instance:FindFirstChildWhichIsA("Decal")
- local decal1 = gibModel:FindFirstChildWhichIsA("Decal")
- if (decal1 and decal) then
- decal1.Texture = decal.Texture
- decal:Destroy()
- end
- local originNormal = character.Head.CFrame.LookVector
- local cur = 0
- for _,gib in pairs(Assets.Gibs.Debris:GetChildren()) do
- local force = originNormal - (2 * originNormal:Dot(cast.Normal) * cast.Normal)
- local dir = force * math.random(15, 35) + Vector3.new(0, math.random(5, 15), 0)
- local gib = gib:Clone()
- gib.CFrame = cast.Instance.CFrame + Vector3.new(math.random(-1, 1) / 10, math.random(-1, 1) / 10, math.random(-1, 1) / 10)
- gib.Velocity = dir + Vector3.new(
- math.random(-500, 500) / 100,
- math.random(-500, 500) / 100,
- math.random(-500, 500) / 100
- )
- gib.RotVelocity = gib.Velocity / 2
- gib.Color = cast.Instance.Color
- gib.Parent = workspace.Ignored
- Debris:AddItem(gib, 0.85)
- local force = Instance.new("BodyForce")
- force.Force = Vector3.new(0, gib:GetMass() * 100, 0)
- force.Parent = gib
- cur += 1
- if (math.random(3) == 1 and cur > 1) then
- break
- end
- end
- else
- local gibObject = cast.Instance.GIBS.Value
- gibObject:Destroy()
- local neckModel = Assets.Gibs.Neck:Clone()
- neckModel.Skin.Color = cast.Instance.Color
- neckModel.Parent = workspace.Ignored
- local neckWeld = Instance.new("Weld")
- neckWeld.Part0 = cast.Instance
- neckWeld.Part1 = neckModel
- neckWeld.Parent = neckModel
- cast.Instance.CollisionGroupId = 2
- cast.Instance.GIBS.Value = neckModel
- task.spawn(function()
- local blood_settings = {
- ["spreadness"] = 2,
- ["amount"] = math.random(15, 20),
- ["process"] = {15, 20, 100},
- ["size"] = {60, 150, 100},
- ["tweenIn"] = TweenInfo.new(0.8, Enum.EasingStyle.Quint),
- ["mode"] = "track",
- ["parent"] = neckModel,
- ["drain"] = true,
- }
- handleBlood(neckModel, cast.Position + (cast.Normal / 100), neckModel.CFrame.UpVector * math.random(150, 200), {model, cast.Instance, workspace.Ignored}, blood_settings)
- end)
- local connection
- connection = model.Destroying:Connect(function()
- connection:Disconnect()
- neckModel:Destroy()
- end)
- cast.Instance:ClearAllChildren()
- end
- elseif (string.find(cast.Instance.Name, "Arm") or string.find(cast.Instance.Name, "Leg")) then
- if (not cast.Instance:FindFirstChild("GIBS")) then
- for _,sound in pairs(model.Head:GetChildren()) do
- if (sound.Name == "hurt") then
- sound:Destroy()
- end
- end
- local sound = playsound(getRandomChild(Assets.Sounds.hurt), model.Head, 0.25)
- sound.Name = "hurt"
- for _,wound in pairs(cast.Instance:GetChildren()) do
- if (wound.Name == "wound") then
- wound:Destroy()
- end
- end
- cast.Instance.Transparency = 1
- local gibModel = getRandomChild(Assets.Gibs.Limbs[gib]):Clone()
- for _,skin in pairs(gibModel:GetDescendants()) do
- if (skin:IsA("BasePart") and (skin.Name == "Skin" or skin.Name == "Debris")) then
- skin.Color = cast.Instance.Color
- end
- end
- local weld = Instance.new("Weld")
- weld.Part0 = cast.Instance
- weld.Part1 = gibModel.Attach
- weld.Parent = gibModel
- --[[local shirtInstance = model:FindFirstChildWhichIsA("Shirt")
- if (shirtInstance and gibModel.Attach:FindFirstChild("Skin")) then
- local shirt = Instance.new("SurfaceAppearance")
- shirt.Parent = gibModel.Attach.Skin
- shirt.ColorMap = shirtInstance.ShirtTemplate
- end]]
- gibModel.Name = model.Name .. "_" .. gibModel.Name
- gibModel.Parent = workspace.Ignored
- local gibs = Instance.new("ObjectValue")
- gibs.Name = "GIBS"
- gibs.Value = gibModel
- gibs.Parent = cast.Instance
- local debrisWeld = gibModel.Attach:FindFirstChild("Debris")
- if (debrisWeld) then
- task.delay(1 / 30, function()
- debrisWeld:Destroy()
- 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)
- gibModel.Debris.RotVelocity = gibModel.Debris.Velocity
- local force = Instance.new("BodyForce")
- force.Force = Vector3.new(0, gibModel.Debris:GetMass() * 120, 0)
- force.Parent = gibModel.Debris
- end)
- end
- task.spawn(function()
- local blood_settings = {
- ["spreadness"] = 2,
- ["amount"] = math.random(15, 20),
- ["process"] = {15, 20, 100},
- ["size"] = {60, 150, 100},
- ["tweenIn"] = TweenInfo.new(0.8, Enum.EasingStyle.Quint),
- ["mode"] = "track",
- ["parent"] = gibModel.Attach,
- ["drain"] = true,
- ["meat"] = true,
- ["meatAmount"] = math.random(6, 8)
- }
- handleBlood(gibModel.Attach, cast.Position + (cast.Normal / 100), dir.unit * math.random(20, 30), {model, cast.Instance, workspace.Ignored}, blood_settings)
- end)
- if (gibModel:FindFirstChild("Debris")) then
- task.spawn(function()
- local blood_settings = {
- ["spreadness"] = 2,
- ["amount"] = math.random(8, 12),
- ["process"] = {45, 50, 100},
- ["size"] = {60, 240, 100},
- ["tweenIn"] = TweenInfo.new(0.8, Enum.EasingStyle.Quint),
- ["mode"] = "track",
- ["parent"] = gibModel.Debris,
- ["drain"] = true,
- }
- handleBlood(gibModel.Debris, cast.Position + (cast.Normal / 100), gibModel.Debris.CFrame.UpVector * -5, {model, cast.Instance, workspace.Ignored}, blood_settings)
- end)
- end
- local connection
- connection = model.Destroying:Connect(function()
- connection:Disconnect()
- gibModel:Destroy()
- end)
- local originNormal = character.Head.CFrame.LookVector
- local cur = 0
- for _,gib in pairs(Assets.Gibs.Debris:GetChildren()) do
- local force = originNormal - (2 * originNormal:Dot(cast.Normal) * cast.Normal)
- local dir = force * math.random(15, 35) + Vector3.new(0, math.random(5, 15), 0)
- local gib = gib:Clone()
- gib.CFrame = cast.Instance.CFrame + Vector3.new(math.random(-1, 1) / 10, math.random(-1, 1) / 10, math.random(-1, 1) / 10)
- gib.Velocity = dir + Vector3.new(
- math.random(-500, 500) / 100,
- math.random(-500, 500) / 100,
- math.random(-500, 500) / 100
- )
- gib.RotVelocity = gib.Velocity / 2
- gib.Color = cast.Instance.Color
- gib.Parent = workspace.Ignored
- Debris:AddItem(gib, 0.85)
- local force = Instance.new("BodyForce")
- force.Force = Vector3.new(0, gib:GetMass() * 100, 0)
- force.Parent = gib
- cur += 1
- if (math.random(3) == 1 and cur > 1) then
- break
- end
- end
- else
- end
- end
- end
- --
- end)
- end)
- playsound(getRandomChild(Assets.Sounds.bullet_flesh), cast.Position, 0.5)
- if (not cast.Instance:FindFirstChild("GIBS")) then
- -- // blood and wounds
- handleWound(cast, model, originPos)
- --
- -- // exit wound
- do
- local params = RaycastParams.new()
- params.FilterDescendantsInstances = {model}
- params.FilterType = Enum.RaycastFilterType.Include
- params.CollisionGroup = "Raycast"
- local origin, dir1 = cast.Position + dir.unit * getSize(cast.Instance), dir.unit * -dir.magnitude
- local cast = workspace:Raycast(origin, dir1, params)
- local startLine, endLine
- if (cast) then
- startLine, endLine = debugLine(origin, cast.Position)
- if (startLine) then
- startLine.Beam.Color = ColorSequence.new(Color3.fromRGB(0, 255, 0))
- end
- handleWound(cast, model, cast.Position + cast.Normal / 20)
- local blood_settings = {
- ["spreadness"] = 2,
- ["amount"] = math.random(10, 12),
- ["process"] = {10, 15, 100},
- ["size"] = {50, 140, 100},
- ["mode"] = "track",
- ["parent"] = cast.Instance,
- ["tweenIn"] = TweenInfo.new(0.5, Enum.EasingStyle.Sine),
- ["drain"] = true,
- }
- task.spawn(function()
- handleBlood(model, cast.Position + cast.Normal / 20, dir.unit * 50, ignore, blood_settings)
- end)
- else
- startLine, endLine = debugLine(origin, dir1)
- end
- end
- --
- end
- -- // reflect blood
- if (math.random(5) == 1 or death) then
- task.spawn(function()
- local originNormal = character.Head.CFrame.LookVector
- -- // ray reflection
- local force = originNormal - (2 * originNormal:Dot(cast.Normal) * cast.Normal)
- local dir = force * math.random(15, 20) + Vector3.new(0, math.random(5, 10), 0)
- local amount = (gunData.settings.shotgun.enabled and gunData.settings.damage / gunData.settings.shotgun.amount or gunData.settings.damage) * 3.5
- local blood_settings = {
- ["spreadness"] = 2,
- ["amount"] = math.random(amount / 2, amount),
- ["process"] = {10, 15, 100},
- ["size"] = {15, 40, 100},
- ["mode"] = "track",
- ["parent"] = cast.Instance.Name == "HumanoidRootPart" and cast.Instance.Parent.Torso or cast.Instance,
- ["tweenIn"] = TweenInfo.new(0.25, Enum.EasingStyle.Quint),
- ["drain"] = true;
- }
- handleBlood(model, cast.Position, dir, ignore, blood_settings)
- end)
- end
- ---
- -- // reflect fast blood
- task.spawn(function()
- local originNormal = character.Head.CFrame.LookVector
- -- // ray reflection
- local force = originNormal - (2 * originNormal:Dot(cast.Normal) * cast.Normal)
- local dir = force * math.random(10, 15) + Vector3.new(0, math.random(5), 0)
- local amount = (gunData.settings.shotgun.enabled and gunData.settings.damage / gunData.settings.shotgun.amount or gunData.settings.damage) / 5
- local blood_settings = {
- ["spreadness"] = 30,
- ["amount"] = math.random(amount / 2, amount),
- ["process"] = {1, 2, 500},
- ["size"] = {15, 40, 100},
- ["mode"] = "track",
- ["parent"] = cast.Instance.Name == "HumanoidRootPart" and cast.Instance.Parent.Torso or cast.Instance,
- ["tweenIn"] = TweenInfo.new(0.25, Enum.EasingStyle.Quint),
- }
- handleBlood(model, cast.Position, dir, ignore, blood_settings)
- end)
- ---
- -- // piercing blood
- local amount = (gunData.settings.shotgun.enabled and gunData.settings.damage / gunData.settings.shotgun.amount or gunData.settings.damage) / 2
- local blood_settings = {
- ["spreadness"] = 3,
- ["amount"] = math.random(amount / 2, amount),
- ["process"] = {1, 2, 500},
- ["size"] = {15, 80, 100},
- ["tweenIn"] = TweenInfo.new(0.05, Enum.EasingStyle.Quint),
- ["singleSegment"] = true;
- ["meat"] = cast.Instance.Name == "Head",
- ["meatAmount"] = math.random(amount / 2, amount),
- }
- handleBlood(model, cast.Position, mouse.UnitRay.Direction * 50, ignore, blood_settings)
- ---
- else
- local bulletHole = Assets.Bloods.bulletHole:Clone()
- local size = math.random(25, 30) / 100
- bulletHole.Size = Vector3.new(size, 0, size)
- bulletHole.CFrame = CFrame.new(cast.Position, cast.Position + cast.Normal) * CFrame.Angles(math.rad(-90), math.rad(math.random(-90, 90)), 0)
- bulletHole.Parent = cast.Instance
- local weld = Instance.new("WeldConstraint")
- weld.Part0 = cast.Instance.Name == "HumanoidRootPart" and cast.Instance.Parent.Torso or cast.Instance
- weld.Part1 = bulletHole
- weld.Parent = bulletHole
- Debris:AddItem(bulletHole, config.decal_cleanup_time)
- task.delay(config.decal_cleanup_time - 0.5, function()
- pcall(function()
- TweenService:Create(bulletHole.Decal, TweenInfo.new(0.5, Enum.EasingStyle.Sine), {Transparency = 1}):Play()
- end)
- end)
- end
- else
- debugLine(origin, origin + dir, 1)
- endTracer.WorldPosition = origin + dir
- end
- -- // beam transparency tween
- local current = 0.9
- local connection
- connection = RunService.RenderStepped:Connect(function(dt)
- dt *= 60
- if (current >= 1 or not beamTracer:IsDescendantOf(workspace)) then
- connection:Disconnect()
- return
- end
- current = lerp(current, 1, 0.05 * dt)
- beamTracer.Transparency = NumberSequence.new(current)
- end)
- Debris:AddItem(startTracer, 1.5)
- Debris:AddItem(endTracer, 1.5)
- Debris:AddItem(beamTracer, 1.5)
- end
- --while gunData.settings.reload.CurrAmm <=0 do
- -- reloadWeapon(gunData)
- -- return
- --end
- while UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) or isMobile == 1 do
- if gunData.settings.reload.CurrAmm <= 0 then
- reloadWeapon(gunData)
- break
- else
- task.wait()
- if isReloading then task.wait() continue end
- if (tick() - delay >= gunData.settings.rate and tick() - equipDelay >= gunData.settings.equip_time) then
- delay = tick()
- Assets.Events.ToolLoader:Fire(gunTool, "stopAnims", {"idle"}, unique_id)
- Assets.Events.ToolLoader:Fire(gunTool, "anims", "fire", unique_id)
- local recoil = Vector3.new(
- math.random(gunData.settings.recoil.x[1], gunData.settings.recoil.x[2]),
- math.random(gunData.settings.recoil.y[1], gunData.settings.recoil.y[2]),
- math.random(gunData.settings.recoil.z[1], gunData.settings.recoil.z[2])
- )
- springCam.Speed = gunData.settings.recoil_speed
- springCam.Damper = gunData.settings.recoil_damp
- springCam:Impulse(recoil)
- task.delay(1 / 15, function()
- springCam.Speed = gunData.settings.recoil_speed * gunData.settings.recoil_back_threshold
- springCam.Damper = gunData.settings.recoil_damp / gunData.settings.recoil_back_threshold
- springCam:Impulse(-recoil / gunData.settings.recoil_back)
- end)
- playsound(getRandomChild(gunTool.Sounds.Fire), gunTool.Handle.Muzzle, 0.4)
- playsound(gunTool.Sounds.Echo, gunTool.Handle.Muzzle, 0.6)
- for _,instance in pairs(gunTool.Handle.Muzzle:GetChildren()) do
- if (instance:IsA("ParticleEmitter")) then
- instance:Emit(instance.Rate)
- elseif (instance.Name == "FlashLight") then
- local newInstance = instance:Clone()
- newInstance.Name = ""
- newInstance.Enabled = true
- newInstance.Parent = gunTool.Handle.Muzzle
- Debris:AddItem(newInstance, 1 / 40)
- end
- end
- if (gunData.settings.shotgun.enabled) then
- for k = 1, gunData.settings.shotgun.amount do
- isMobile = 0
- task.spawn(fire)
- end
- else
- isMobile = 0
- task.spawn(fire)
- end
- if (not gunData.settings.auto) then
- break
- end
- end
- task.wait()
- end
- end
- end
- UserInputService.InputBegan:Connect(function(input, typing)
- if (not typing) then
- if (input.UserInputType == Enum.UserInputType.MouseButton1 and character:FindFirstChild("Head") and equippingGun and gunTool) then
- Fireeee()
- elseif (input.UserInputType ~= Enum.UserInputType.MouseButton1 and character:FindFirstChild("Head") and equippingGun and gunTool) then
- local gunData, unique_id = findTool(gunTool)
- if (tick() - delay < gunData.settings.rate) then
- return
- end
- gunData.tool:SetAttribute("CurrAmmo", gunData.settings.reload.CurrAmm)
- end
- end
- end)
- UserInputService.InputBegan:Connect(function(key)
- if key.UserInputType == Enum.UserInputType.Gamepad1 then
- if key.KeyCode == Enum.KeyCode.ButtonR2 and character:FindFirstChild("Head") and equippingGun and gunTool then
- Fireeee(1)
- -- print("firing")
- elseif (key.KeyCode == Enum.KeyCode.Z and character:FindFirstChild("Head") and equippingGun and gunTool) then
- local gunData, unique_id = findTool(gunTool)
- if (tick() - delay < gunData.settings.rate) then
- return
- end
- gunData.tool:SetAttribute("CurrAmmo", gunData.settings.reload.CurrAmm)
- end
- end
- end)
- task.spawn(function()
- while humanoid.Health > 0 and humanoid.RootPart and humanoid:IsDescendantOf(workspace) do
- for index,data in pairs(bloodParts) do
- if (data.part and data.placed) then
- if (getDistance(data.part, camera.CFrame.Position) > config.blood_render_distance) then
- data.part.Parent = nil
- elseif (not destroyed(data.part)) then
- data.part.Parent = workspace.Ignored
- end
- end
- end
- for index,data in pairs(woundParts) do
- if (woundParts[index]) then
- for _,part in pairs(data) do
- if (getDistance(part, camera.CFrame.Position) > config.wound_render_distance) then
- part.Parent = nil
- elseif (not destroyed(part)) then
- part.Parent = workspace.Ignored
- end
- end
- end
- end
- for index,data in pairs(meatParts) do
- if (meatParts[index]) then
- if (getDistance(meatParts[index], camera.CFrame.Position) > config.meat_render_distance) then
- meatParts[index].Parent = nil
- elseif (not destroyed(meatParts[index])) then
- meatParts[index].Parent = workspace.Ignored
- end
- end
- end
- task.wait(config.render_process)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment