I am working on a movement system which includes physical animations and for that i need a R15 ragdoll as soon as the player spawn.
Problem is: the ragdoll spawning behavior is literally random
Sometimes it spawns with joints:
even though i am explicitly deleting them on the ragdoll creating function
for i,v in pairs(c:GetDescendants()) do
if v:IsA("Motor6D") and v.Name ~= "RootJoint" then
local at = it("Attachment",v.Part0)
at.Name = ("attacher")
at.Position = v.C0.p
local at2 = it("Attachment",v.Part1)
at2.Name = ("attacher2")
at2.Position = v.C1.p
local b = it("BallSocketConstraint",v.Parent)
b.LimitsEnabled = true
b.Attachment0 = at
b.Attachment1 = at2
b.Name = "bsc"
table.insert(partprop,v.Name)
table.insert(partprop,v.Parent)
table.insert(partprop,v.Part0)
table.insert(partprop,v.Part1)
table.insert(partprop,v.C0)
table.insert(partprop,v.C1)
v:Destroy()
end
end
v:Destroy()
^^^^
and sometimes it just works???
The ragdolls move using alignposition and alignorientation to their puppet respective bodyparts, but there’s no way those are causing this problem.
what am i doing wrong?
Thanks in advance.
Note: the ragdolls are literally clones of the player’s character.
Hello, sorry for the late answer.
I tried what you told me to do although nothing happened it’s still the same problem:
code changed to:
function ragdoll(c)
local hu=c.Humanoid
local a=hu:LoadAnimation(script:WaitForChild("AimingL"))
local rval = it("BoolValue",c)
rval.Name="Ragdolled"
rval.Value = true
local fol = it("Folder",c)
fol.Name = "ragdparts"
if c:FindFirstChild("Humanoid") then c.Humanoid.PlatformStand = true end
for i=1,2 do
for i,v in pairs(c:GetDescendants()) do
if v.Name == "attacher" or v.Name == "attacher2" or v.Name == "bsc" or v.Name == "colpart" then
v:Destroy()
end
end
end
for i,v in pairs(c:GetChildren()) do
if v:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(v,ragroup)
v.Massless = true
cpart(v)
end
end
for i,v in pairs(c:GetDescendants()) do
if v:IsA("Motor6D") and v.Name ~= "RootJoint" then
local at = it("Attachment",v.Part0)
at.Name = ("attacher")
at.Position = v.C0.p
local at2 = it("Attachment",v.Part1)
at2.Name = ("attacher2")
at2.Position = v.C1.p
local b = it("BallSocketConstraint",v.Parent)
b.LimitsEnabled = true
b.Attachment0 = at
b.Attachment1 = at2
b.Name = "bsc"
table.insert(partprop,v.Name)
table.insert(partprop,v.Parent)
table.insert(partprop,v.Part0)
table.insert(partprop,v.Part1)
table.insert(partprop,v.C0)
table.insert(partprop,v.C1)
v:Destroy()
end
end
end
Already am, using Ball in socket constraints, though no problems, i just found the solution.
I have no idea why, but the problem is actually an inconsistency with server–>client .
Even though the motors are being deleted on the server, they still persist on the client
As seen here on client:
(notice the several joints, "LeftFoot
VS on the server:
This makes literally no sense in my head, considering that things deleted on the server shouldn’t persist on the client?
Oh well
Problem’s easy to solve now, i can just clone this local script on the character after the motors are deleted on the server
local body=script.Parent:WaitForChild("Body")
local Motors={}
for _,v in pairs(body:GetDescendants()) do
if v:IsA("Motor6D") then
table.insert(Motors,v)
end
end
print("Found a total of: "..#Motors.." Client sided motors")
print("Removing. . .")
for i=1,#Motors do
print("Removed "..Motors[i].Name)
Motors[i]:Destroy()
end
print("Successfully cleaned client motors")