Axolotleless

Ragdoll and damage on explosion

Jun 9th, 2025 (edited)
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.75 KB | None | 0 0
  1.  
  2. local Char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()--shoulda used this
  3.  
  4. local function Ragdoll()--Ragdoll the player
  5.     for _, v in pairs(Char:GetDescendants()) do --Char = player.Character
  6.         if v:IsA("Motor6D") then
  7.             local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
  8.             Att0.CFrame = v.C0
  9.             Att1.CFrame = v.C1
  10.             Att0.Parent = v.Part0
  11.             Att0.Name = "Att0"
  12.             Att1.Name = "Att1"
  13.            
  14.             Att1.Parent = v.Part1
  15.             local BSC = Instance.new("BallSocketConstraint")
  16.             BSC.Attachment0 = Att0
  17.             BSC.Attachment1 = Att1
  18.             BSC.Parent = v.Part0
  19.             BSC.LimitsEnabled = true
  20.             BSC.MaxFrictionTorque = 50
  21.             BSC.TwistLimitsEnabled = true
  22.             BSC.UpperAngle = 90
  23.             BSC.TwistLowerAngle = -90
  24.             BSC.TwistUpperAngle = 90
  25.             BSC.Name = "BSC"--bbc lmao
  26.             v.Enabled = false
  27.         end
  28.     end
  29.     --Char.HumanoidRootPart.CanCollide = true
  30. end
  31.  
  32. local function Unragdoll()--Unragdoll the player
  33.     for _, v in pairs(Char:GetDescendants()) do
  34.         if v:IsA("Motor6D") then
  35.             local Att0 = v.Part0:FindFirstChild("Att0")
  36.             local Att1 = v.Part1:FindFirstChild("Att1")
  37.             local BSC = v.Part0:FindFirstChild("BSC")
  38.            
  39.             Att0:Destroy()--Remove all constraints
  40.             Att1:Destroy()
  41.             BSC:Destroy()
  42.             v.Enabled = true--make this efficient by enabling and disable Motor6ds
  43.         end
  44.     end
  45.    
  46.     --Char.HumanoidRootPart.CanCollide = true
  47. end
  48.  
  49.  
  50. local Players = game:GetService("Players")
  51. local player = Players.LocalPlayer
  52. local character = player.Character or player.CharacterAdded:Wait()--idk why I have to char values i shoulda used the old one lol
  53.  
  54.  
  55. local function checkProximity(explosion)--the part where it actually checks the explosions
  56.     local explosionPosition = explosion.Position--check for pos
  57.     local characterPosition = character.HumanoidRootPart.Position--check for char pos
  58.     local distance = (explosionPosition - characterPosition).Magnitude--dist value
  59.    
  60.    
  61.     if distance <= explosion.BlastRadius then--detect
  62.         character.Humanoid.Health -= 15--dmg value of explosions
  63.         Ragdoll()
  64.         character.Humanoid.PlatformStand = true
  65.         task.wait(3)--this number is basically how long you want the player to be ragdolled
  66.         character.Humanoid.PlatformStand = false
  67.         Unragdoll()
  68.     end
  69. end
  70.  
  71.  
  72. game.DescendantAdded:Connect(function(descendant)
  73.     if descendant:IsA("Explosion") then
  74.         checkProximity(descendant)--check for hot explosions nearby
  75.     end
  76. end)
  77.  
Advertisement
Add Comment
Please, Sign In to add comment