So I have made an R6 Ragdoll but when it resets to normal character again it flops like a fish Im just wondering any ideas for a seamless transition from ragdoll to back to regular character
game.Players.PlayerAdded:Connect(function(plyr)
plyr.CharacterAdded:Connect(function(char)
local value = Instance.new("BoolValue", char)
value.Name = "Ragdoll"
value = false
char.Ragdoll.Changed:Connect(function(newVal)
print("Changed")
char.Humanoid.JumpPower = 0
char.Humanoid.WalkSpeed = 0
if newVal == true then
wait()
ragdollChar(char)
elseif newVal == false then
wait()
resetChar(char)
end
wait(.5)
char.Humanoid.JumpPower = 50
char.Humanoid.WalkSpeed = 16
end)
end)
end)
joints = {} welds = {} fakeLimbs = {}
ragdolling = false
function resetChar(char)
if ragdolling then
local leftArm = char["Left Arm"]
local rightArm = char["Right Arm"]
local leftLeg = char["Left Leg"]
local rightLeg = char["Right Leg"]
local head = char.Head
local torso = char.Torso
char.Torso["Left Hip"].Part0 = torso
char.Torso["Right Hip"].Part0 = torso
char.Torso["Right Shoulder"].Part0 = torso
char.Torso["Left Shoulder"].Part0 = torso
for i,v in pairs(char.Torso:GetChildren()) do
if v.ClassName == "Glue" then
v:Destroy()
end
end
ragdolling = false
wait()
for _, this in pairs(fakeLimbs) do
this:Destroy() -- destroy temp parts
end
leftArm.CanCollide = false
rightArm.CanCollide = false
leftLeg.CanCollide = false
rightLeg.CanCollide = false
char.Humanoid.PlatformStand = false
wait(.6)
leftArm.CanCollide = t
rightArm.CanCollide = true
leftLeg.CanCollide = true
rightLeg.CanCollide = true
end
end
function ragdollChar(char)
if not ragdolling then
ragdolling = true; char.Humanoid.PlatformStand = true
local leftArm = char["Left Arm"]
local rightArm = char["Right Arm"]
local leftLeg = char["Left Leg"]
local rightLeg = char["Right Leg"]
local head = char.Head
local torso = char.Torso
local function cloneJoints(character)
for _,this in ipairs(character.Torso:GetChildren()) do
if this:isA("Motor6D") and this.Name ~= "Neck" then
joints[this.Name] = this:Clone()
end
end
end
local function createGlue(part0, part1, name)
local glue = Instance.new("Glue", torso)
glue.Part0 = part0;glue.Part1 = part1;glue.Name = name
welds[#welds+1] = glue
return glue
end
local function createLimb(parent, position, size)
local limb = Instance.new("Part", parent)
limb.Position = position;limb.Size = size;limb.Transparency = 1
fakeLimbs[#fakeLimbs+1] = limb
return limb
end
local function createWeld(parent, p0, p1)
local weld = Instance.new("Weld", parent)
weld.Part0 = p0;weld.Part1 = p1;
weld.C0 = CFrame.new(0,-0.2,0) * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/2)
welds[#welds+1] = weld
return weld
end
cloneJoints(char)
-- LEFT LEG --
char.Torso["Left Hip"].Part0 = nil
local glue = createGlue(torso, leftLeg, "Left leg")
glue.C0 = CFrame.new(-0.5, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
glue.C1 = CFrame.new(-0, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
local fakeLeftLeg = createLimb(leftLeg, Vector3.new(0,999,0), Vector3.new(1.5, 1, 1))
createWeld(fakeLeftLeg, leftLeg, fakeLeftLeg)
-- RIGHT LEG --
char.Torso["Right Hip"].Part0 = nil
local glue = createGlue(torso, rightLeg, "Right leg")
glue.C0 = CFrame.new(0.5, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
glue.C1 = CFrame.new(0, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
local fakeRightLeg = createLimb(rightLeg, Vector3.new(0,999,0), Vector3.new(1.5, 1, 1))
createWeld(fakeRightLeg, rightLeg, fakeRightLeg)
-- RIGHT ARM --
char.Torso["Right Shoulder"].Part0 = nil
local glue = createGlue(torso, rightArm, "Right shoulder")
glue.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
glue.C1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
local fakeRightArm = createLimb(rightArm, Vector3.new(0,999,0), Vector3.new(1.8,1,1))
createWeld(fakeRightArm, rightArm, fakeRightArm)
-- LEFT ARM --
char.Torso["Left Shoulder"].Part0 = nil
local glue4 = createGlue(torso, leftArm, "Left shoulder")
glue4.C0 = CFrame.new(-1.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
glue4.C1 = CFrame.new(0, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
local fakeLeftArm = createLimb(leftArm, Vector3.new(0,999,0), Vector3.new(1.5, 1, 1))
createWeld(fakeLeftArm, leftArm, fakeLeftArm)
end
end
Should I change to ballsocket constraints instead of glue?
Example:
https://i.gyazo.com/e5b4c6a234c9b22313780d23e68a2d3d.mp4