I’m trying to create a ragdoll function. It works, but it shoots the character into the air.
Server script:
local d = char:GetDescendants()
for i=1,#d do
local desc = d[i]
if desc:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local part0 = desc.Part0
local joint_name = desc.Name
local attachment0 = desc.Parent:FindFirstChild(joint_name.."Attachment") or desc.Parent:FindFirstChild(joint_name.."RigAttachment")
local attachment1 = part0:FindFirstChild(joint_name.."Attachment") or part0:FindFirstChild(joint_name.."RigAttachment")
if attachment0 and attachment1 then
socket.Attachment0, socket.Attachment1 = attachment0, attachment1
socket.Parent = desc.Parent
desc:Destroy()
end
end
end
Hmm. I think that this happens because constraint is trying to snap 2 attachments together, and one of them is somewhere up in the air. You should make attachments visible and see if there’s any attachment in the air.
I have tried this in baseplate, everything works fine and character ragdolls as he should. I’ve noticed that this scrpt doesn’t work with R6.
I think that this affects only your game. Try to find anything that interacts with character in any way.
I think that the tool is the cause for this. Try to save your tool to a file, open a baseplate, insert an R15 rig (plugins tab → rig builder), insert your tool into starter pack and see if it still flies.
I inserted the ragdoll script in a random baseplate without the weapon and called it on the character when the player is added and it still flies.
Here are both scripts if needed.
Server:
game.ReplicatedStorage.Remotes.Ragdoll.OnServerEvent:Connect(function(p,char)
local d = char:GetDescendants()
for i=1,#d do
local desc = d[i]
if desc:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local part0 = desc.Part0
local joint_name = desc.Name
local attachment0 = desc.Parent:FindFirstChild(joint_name.."Attachment") or desc.Parent:FindFirstChild(joint_name.."RigAttachment")
local attachment1 = part0:FindFirstChild(joint_name.."Attachment") or part0:FindFirstChild(joint_name.."RigAttachment")
if attachment0 and attachment1 then
socket.Attachment0, socket.Attachment1 = attachment0, attachment1
socket.Parent = desc.Parent
desc:Destroy()
end
local new = Instance.new("BodyVelocity")
new.Velocity = Vector3.new(0,-100,0)
new.Parent = char.HumanoidRootPart
end
end
end)
Client:
local p = game.Players.LocalPlayer
game.ReplicatedStorage.Remotes.Ragdoll:FireServer(p.Character)
game.ReplicatedStorage.Remotes.Killed.OnClientEvent:Connect(function(player)
game.SoundService.SoundEffects.Kill:Play()
game.ReplicatedStorage.Remotes.Ragdoll:FireServer(player.Character)
end)