Hey everyone! i am working on a ragdoll mechanic on my game and i got this bug where the player does not respawn if they die while being ragdolled. i want to know if there is a way i can fix this! i have tried researching on this but all the posts i found were on a different topic.
this is a gif of the bug:
https://gyazo.com/47910628a3084856bbe74f3d031529af
well, hard to see the bug because gyazo only allows 7 seconds.
i could post my lua code but its too long!
At any point in the script is game.Players.CharacterAutoLoads set to false?
Nope i don’t remember touching that property while scripting it.
Could you send the script anyway? It’d help us understand much better.
2 Likes
local Motors2 = {}
local Debree = {}
local module = {}
function module:RagdollCharacter(plr,Character, Enabled)
local plrvalues = game.ReplicatedStorage.PlayerValues:FindFirstChild(plr.Name) or Character
if Enabled == true and Debree[plr] ==nil and plrvalues ~= nil and Character ~= nil and Character:FindFirstChild("Humanoid") ~= nil and Character:FindFirstChild("HumanoidRootPart") ~= nil and Character:FindFirstChild("aklsdajksdbhhauisdasdasd",true) == nil then
print("Ragdoll")
local Parts = {}
local Motors = {"RootJoint","Left Hip","Right Hip","Left Shoulder","Right Shoulder","Neck"}
Motors2[plr] = {}
Debree[plr] = {}
if Character:FindFirstChild("Humanoid") ~= nil then
Character.Humanoid.PlatformStand = true
end
for i,v in pairs(Motors) do
local Child = Character:FindFirstChild(v,true)
if Child ~= nil and Child:IsA("Motor6D") and Child.Part1 ~= nil then
table.insert(Motors2[plr],{Child,Child.Part1})
local C0 = Child.C0
local C1 = Child.C1
local Part0 = Child.Part0
local Part1 = Child.Part1
Child.Part1 = nil
table.insert(Parts,{C0,C1,Part0,Part1})
end
end
for i,v in pairs(Parts) do
local A1,A2 = Instance.new("Attachment"),Instance.new("Attachment")
A1.Parent = v[3]
A2.Parent = v[4]
if v[4].Name ~= "Left Leg" and v[4].Name ~= "Right Leg" then
A1.CFrame = CFrame.new( math.sign(v[1].X)*1.55 ,v[1].Y,0 )
A2.CFrame = CFrame.new(0,v[2].Y,0 )
else
A1.CFrame = CFrame.new( math.sign(v[1].X,-.5,.5)*.55 ,math.sign(v[1].Y)*1.2 ,0 )
A2.CFrame = CFrame.new(0,v[2].Y,0 )
end
local B1 = Instance.new("BallSocketConstraint")
B1.Parent = v[3]
B1.Name = "aklsdajksdbhhauisdasdasd"
B1.Attachment0 = A1
B1.Attachment1 = A2
if v[4].Name ~= "Head" and v[4].Name ~= "Torso" then
local P = Instance.new("Part")
P.Size = Vector3.new(1,1,1)
P.Parent = Character
P.Transparency = 1
P.Anchored = false
P.CanCollide = true
local W = Instance.new("Weld")
W.Part0 = v[4]
W.Part1 = P
W.Parent = P
W.C0 = CFrame.new(0,-.5,0)
table.insert(Debree[plr],P)
elseif v[4].Name == "Head" then
local P = Instance.new("Part")
P.Size = Vector3.new(.3,.3,.3)
P.Parent = Character
P.Transparency = 1
P.Anchored = false
P.CanCollide = true
local W = Instance.new("Weld")
W.Part0 = v[4]
W.Part1 = P
W.Parent = P
table.insert(Debree[plr],P)
end
table.insert(Debree[plr],A1);table.insert(Debree[plr],A2);table.insert(Debree[plr],B1);
end
else
if plr ~= nil and plr:IsA("Model") then
if plr:FindFirstChild("Humanoid") ~= nil and plrvalues:FindFirstChild("PI") == nil then
plr.Humanoid.PlatformStand = false
plr.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
else
if plr ~= nil and plr.Character ~= nil and plr.Character:FindFirstChild("Humanoid") ~= nil and plrvalues:FindFirstChild("PI") == nil then
plr.Character.Humanoid.PlatformStand = false
plr.Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end
if Character ~= nil and Character:FindFirstChild("HumanoidRootPart") ~= nil then
for i,v in pairs(Character:GetChildren()) do
if v:IsA("BasePart") and v.Anchored == false then
v.RotVelocity = Vector3.new()
v.Velocity = Vector3.new()
end
end
end
if Motors2[plr] ~= nil then
for i,v in pairs(Motors2[plr]) do
v[1].Part1 = v[2]
end
end
if Debree[plr] ~= nil then
for i,v in pairs(Debree[plr]) do
v:Destroy()
end
end
Debree[plr] = nil
Motors2[plr] = nil
end
end
return module
from the client i’m just setting the humanoid state to ragdoll
I tried manually re spawning the character after 5 seconds and it works fine.
another way to fix this is to not set you’re ragdoll when the humanoid’s state is switched to dead but when the humanoid.died function is called.
2 Likes