Ahoy! From what the title says, I need help with this temporary ragdoll script. What is supposed to happen is when a player’s health is less than or equal to 15 then they ragdoll. But when their health is greater than 15 they are not ragdolled. What happens in the code below is that when the player’s health is 15 or less than that, they do not ragdoll at all. Help would be great!
Here is the script:
wait()
local Character = game.Players.LocalPlayer.Character
local Hm = Character:WaitForChild("Humanoid")
local HmHRP = Character.HumanoidRootPart
local UIS = game:GetService("UserInputService")
local Ragdolling = Instance.new("BoolValue")
Ragdolling.Value = false
Ragdolling.Parent = Character
local SocketType = "BallSocketConstraint"
print(Hm.Health)
if Hm.Health <= 15 then
local PlayerParts = Character:GetDescendants()
for i,M6D in pairs(PlayerParts) do
if M6D:IsA("Motor6D") then
if M6D.Name ~= "Root" then
if not M6D.Parent:FindFirstChildWhichIsA(SocketType) then
local Socket = Instance.new(SocketType)
M6D.Parent = M6D.Part1
Socket.LimitsEnabled = true
Socket.Radius = .25
Socket.TwistLimitsEnabled = false
Socket.TwistLowerAngle = 360
Socket.TwistUpperAngle = -180
Socket.UpperAngle = 90
local M0,M1
if not M6D.Part0:FindFirstChild(M6D.Name .. "RigAttachment") then
print("A")
M0 = Instance.new("Attachment")
M0.Name = M6D.Name .. "RigAttachment"
M0.Parent = M6D.Part0
M0.CFrame = M6D.C0
print(M0.Name .. "A0")
end
if not M6D.Part1:FindFirstChild(M6D.Name .. "RigAttachment") then
M1 = Instance.new("Attachment")
M1.Name = M6D.Name .. "RigAttachment"
M1.Parent = M6D.Part1
M1.CFrame = M6D.C1
print(M1.Name .. "A1")
end
Socket.Parent = M6D.Parent
Socket.Attachment0 = M6D.Part0:FindFirstChild(M6D.Name .. "RigAttachment")
Socket.Attachment1 = M6D.Part1:FindFirstChild(M6D.Name .. "RigAttachment")
game.Workspace.CurrentCamera.CameraSubject = Character.Head
M6D.Enabled = false
Hm:ChangeState(Enum.HumanoidStateType.Physics)
Ragdolling = true
HmHRP.CanCollide = false
end
end
end
end
end
if Hm.Health > 15 then
local PlayerParts = Character:GetDescendants()
if Ragdolling == true then
for i,M6DBSC in pairs(PlayerParts) do
if M6DBSC:IsA(SocketType) then
M6DBSC:Destroy()
elseif M6DBSC:IsA("Motor6D") then
M6DBSC.Enabled = true
end
end
HmHRP.CFrame = HmHRP.CFrame + Vector3.new(0,2,0)
HmHRP.CanCollide = true
game.Workspace.CurrentCamera.CameraSubject = Character.Humanoid
Hm:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end