Guest User

Untitled

a guest
Jan 12th, 2026
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.01 KB | None | 0 0
  1. local LimbDamager = {}
  2. local Players = game:GetService("Players")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4.  
  5. local CastVisualizer = require(ReplicatedStorage.Packages.CastVisuals)
  6. local BloodEffects = require(ReplicatedStorage.Game.Modules.BloodEffects)
  7. local Valid_Limbs = require(ReplicatedStorage.Game.Data.BodyHealthValues)
  8.  
  9. local function QuickCheck(BodyPart: BasePart)
  10.     if BodyPart:IsA("BasePart") then
  11.         for _, Limb in Valid_Limbs do
  12.             if BodyPart.Name == Limb.Name then
  13.                 return Limb
  14.             end
  15.         end
  16.     end
  17. end
  18.  
  19. local function QuickCheck2(BodyPart: BasePart)
  20.     for _, Limb in Valid_Limbs do
  21.         if BodyPart == Limb.Name then
  22.             return Limb
  23.         end
  24.     end
  25. end
  26.  
  27. local function ApplyVelocity(Character: Model,PartApplying,Amount,Dir,NewDir,Limits)
  28.     local Velocity = Instance.new("LinearVelocity", Character.HumanoidRootPart)
  29.  
  30.     Velocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
  31.  
  32.     Velocity.MaxAxesForce = Vector3.new(100000,100000,100000)
  33.  
  34.     local Att0 = Instance.new("Attachment", Character.HumanoidRootPart)
  35.  
  36.     Velocity.Attachment0 = Att0
  37.    
  38.     Velocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
  39.  
  40.     Velocity.VectorVelocity = (NewDir*Limits)*Amount
  41.    
  42.     game.Debris:AddItem(Velocity,0.2)
  43.     game.Debris:AddItem(Att0,0.2)
  44. end
  45.  
  46. function LimbDamager.FindLimb(OriginPart: BasePart,Distance,Face,Velocity,Direction,Duration,Damage,IgnoreTable)
  47.     local Rayparams = RaycastParams.new()
  48.     Rayparams.FilterType = Enum.RaycastFilterType.Exclude
  49.     Rayparams.FilterDescendantsInstances = IgnoreTable or {}
  50.    
  51.     local Direction = OriginPart.CFrame.LookVector * Distance
  52.    
  53.     local Result = workspace:Shapecast(OriginPart,Direction*Face,Rayparams)
  54.    
  55.    
  56.     local CurrentVelocity = OriginPart.AssemblyLinearVelocity.Magnitude
  57.    
  58.     if Result and Result.Instance then
  59.         if QuickCheck(Result.Instance) then
  60.             local RagdollBool = Result.Instance.Parent:FindFirstChild("Ragdoll")
  61.             if RagdollBool.Value ~= true then
  62.                 RagdollBool.Value = true
  63.                
  64.                 local DamageMulti = 0
  65.  
  66.                 ApplyVelocity(Result.Instance.Parent,OriginPart,Velocity,nil,Direction,Face)
  67.                
  68.                 if Velocity < 0 then
  69.                     DamageMulti = (Velocity*-1)*0.05
  70.                 else
  71.                     DamageMulti = Velocity*0.05
  72.                 end
  73.                
  74.                 LimbDamager.DamageLimb(Result.Instance.Parent,Result.Instance.Name,Damage*DamageMulti)
  75.                
  76.                 task.spawn(function()
  77.                     task.wait(Duration)
  78.                     RagdollBool.Value = false
  79.                 end)
  80.             end
  81.            
  82.             return Result.Instance, CurrentVelocity
  83.         else
  84.             return false
  85.         end
  86.     else
  87.         return false
  88.     end
  89. end
  90.  
  91.  
  92. function LimbDamager.DamageLimb(Character: Model,LimbSelected: string,Damage)
  93.     local Player
  94.    
  95.     if Players:GetPlayerFromCharacter(Character) then
  96.         Player = Players:GetPlayerFromCharacter(Character)
  97.     end
  98.    
  99.     local Selected = QuickCheck2(LimbSelected)
  100.    
  101.     local OriginalHealth = Character:GetAttribute(Selected.Name2)
  102.    
  103.     local NewHealth = OriginalHealth - Damage
  104.    
  105.     if Damage > 5 then
  106.         BloodEffects.StartEffects(Character[LimbSelected],Character)
  107.     end
  108.    
  109.     print(NewHealth)
  110.     print(OriginalHealth)
  111.     print(Damage)
  112.    
  113.     if NewHealth < 0 then
  114.         NewHealth = 0
  115.     end
  116.    
  117.     if NewHealth == 0 then
  118.         if not Character:FindFirstChild("Dead_"..LimbSelected) then
  119.             local RealLimb = Character[LimbSelected]:: BasePart
  120.  
  121.             if RealLimb:FindFirstChild("Mesh") then
  122.                 RealLimb.Mesh:Destroy()
  123.             end
  124.  
  125.             local Replacement = ReplicatedStorage.Game.Assets.Gore.Skeleton[LimbSelected]:Clone():: BasePart
  126.  
  127.             Replacement.CanCollide = false
  128.             Replacement.Anchored = false
  129.  
  130.             Replacement.Parent = Character
  131.             Replacement.CFrame = RealLimb.CFrame
  132.  
  133.             RealLimb.Name = "Dead_"..RealLimb.Name
  134.  
  135.             RealLimb.Transparency = 1
  136.            
  137.             for _, Accecory in Character:GetChildren() do
  138.                 if Accecory:IsA("Accessory") then
  139.                     if Accecory.AccessoryType == Enum.AccessoryType.Hat and LimbSelected == "Head" then
  140.                         Accecory:Destroy()
  141.                     end
  142.                 end
  143.             end
  144.            
  145.             for _, obj in RealLimb:GetChildren() do
  146.                 if not RealLimb:FindFirstChild(obj.Name) then
  147.                     obj.Parent = Replacement
  148.                 else
  149.                     obj:Destroy()
  150.                 end
  151.             end
  152.            
  153.             if LimbSelected == "Torso" then
  154.                 local NewWeld = Instance.new("Weld")
  155.                 NewWeld.Parent = Character.HumanoidRootPart
  156.                
  157.                 NewWeld.Part0 = Character.HumanoidRootPart
  158.                 NewWeld.Part1 = Replacement
  159.             end
  160.  
  161.             local Torso = Character.Torso:: BasePart
  162.  
  163.             local Humanoid = Character.Humanoid:: Humanoid
  164.            
  165.             Humanoid.RequiresNeck = false
  166.            
  167.             for _, Motor6d in Character:GetDescendants() do
  168.                 if Motor6d:IsA("Motor6D") then
  169.                     if Motor6d.Part1 == RealLimb then
  170.                         Motor6d.Part1 = Replacement
  171.                     end
  172.                 end
  173.             end
  174.         end
  175.     end
  176.    
  177.     print(NewHealth)
  178.    
  179.     Character:SetAttribute(Selected.Name2,NewHealth)
  180.    
  181.     local TotalHealth = 0
  182.    
  183.     for _, Limb in Valid_Limbs do
  184.         local LimbHealth = Character:GetAttribute(Limb.Name2)
  185.        
  186.         TotalHealth += LimbHealth
  187.        
  188.         if Player then
  189.             ReplicatedStorage.Game.RemoteEvents.LimbHealthChange:FireClient(Player,Limb)
  190.         end
  191.     end
  192.    
  193.     if TotalHealth <= 0 then
  194.         Character.Humanoid.Health = 0
  195.     end
  196. end
  197.  
  198. return LimbDamager
  199.  
Advertisement
Add Comment
Please, Sign In to add comment