Hi, my name is bullet, and recently i have been running into a ton of errors on this one script.
I’ve recently been working on a ragdoll script for a game i’m in a team with, but this has consistently been delaying me from working on any other scripts [ i am the only scripter in the team ]
so i would appreciate some help, but here is the script i am talking about:
local humanoid = script.Parent:WaitForChild("Humanoid")
local HRP = script.Parent:WaitForChild("HumanoidRootPart")
local jointtable = {}
local Ragdoll = Instance.new("BoolValue")
Ragdoll.Value = false
Ragdoll.Name = "Ragdoll"
Ragdoll.Parent = humanoid
task.wait()
if Ragdoll == nil then
print("failed in life")
elseif Ragdoll ~= nil then
local function HumanoidState(OldState, NewState)
if NewState == Enum.HumanoidStateType.Seated and not Ragdoll then
print("things are happening.")
for i,v in pairs(humanoid.Parent:GetDescendants()) do
if v:IsA("Motor6D") and v.Parent.Name ~= "HumanoidRootPart" then
local Socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = v.Part0
a2.Parent = v.Part1
Socket.Parent = v.Parent
Socket.Attachment0 = a1
Socket.Attachment1 = a2
a1.CFrame = v.C0
a2.CFrame = v.C1
Socket.LimitsEnabled = true
Socket.TwistLimitsEnabled = true
v:Destroy()
print("a ballsocket replaced")
end
end
Ragdoll = true
humanoid.RequiresNeck = false
elseif NewState == Enum.HumanoidStateType.Jumping or NewState == Enum.HumanoidStateType.Running and Ragdoll then
for i,v in pairs(humanoid.Parent:GetDescendants()) do
if v:IsA("BallSocketConstraint") then
v.UpperAngle = 0
v.TwistUpperAngle = 0
v.TwistLowerAngle = 0
local Joints = Instance.new("Motor6D",v.Parent)
if v.Attachment1 == nil == nil or v.Attachment1.Parent == nil or v.Attachment1.Parent.Name == nil then
print("nil")
return end
-- THE STAIR CODE!!
if v.Attachment1.Parent.Name == "Head" then
Joints.Name = "Neck"
elseif v.Attachment1.Parent.Name == "Left Arm" then
Joints.Name = "Left Shoulder"
elseif v.Attachment1.Parent.Name == "Right Arm" then
Joints.Name = "Right Shoulder"
elseif v.Attachment1.Parent.Name == "Right Leg" then
Joints.Name = "Right Hip"
elseif v.Attachment1.Parent.Name == "Left Leg" then
Joints.Name = "Left Hip"
end
-- The END OF THE STAIR CODE :(
Joints.Part0 = v.Attachment0.Parent
Joints.Part1 = v.Attachment1.Parent
Joints.C0 = v.Attachment0.CFrame
Joints.C1 = v.Attachment1.CFrame
v:Destroy()
end
end
Ragdoll = false
end
if NewState == Enum.HumanoidStateType.Seated and Ragdoll == false then
elseif NewState == Enum.HumanoidStateType.Jumping and Ragdoll == true then
end
end
humanoid.StateChanged:Connect(HumanoidState)
it’s a long read, but anyways. the error i’m having is with the ragdoll just not working after the first time it works, for example:
I get knocked down and i ragdoll, i get back up, it prints " nil " for whatever reason, then
if i get knocked down again, i don’t ragdoll and no errors pop up, but the prints in the ragdoll code don’t run.
so i would really appreciate some help here, but anyways,
thank you for reading, and if you can help, thanks in advance!