Hey y’all! I’m currently creating a knife that kills people… like most knives… anyways:
It works fine, except for one thing, the ragdoll. I’ve been trying to achieve something like what happens on Murder Mystery 2, where when you kill someone, their body ragdoll’s onto the floor and stays there for the duration of the round.
I do this by cloning their character, and then putting it into the map folder. From there the ragdoll script does it’s stuff. The ragdoll part of the script is identical to the regular death ragdoll script, but it doesn’t work for some reason.
This is when I use a ragdoll clone
As you can see, it just freezes. A cold dead body with no motion. But now let’s use the almost exact same script for when you just die in general.
Ah, much better. This is what I am wanting the ragdoll to do when it spawns in. Here is the coding for both events.
Clone script:
local players = game:GetService("Players")
local collectionService = game:GetService("CollectionService")
local active = false
script.Parent.Parent.Handle.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
if script.Parent.Parent.Active.Value == true and active == false then
active = true
local ownerChar = script.Parent.Parent.Parent
local owner = players:GetPlayerFromCharacter(ownerChar)
local char = part.Parent
local target = players:GetPlayerFromCharacter(char)
if owner ~= char and char.Humanoid.DisplayName ~= "" then
part.Parent.Humanoid.Health = 0
local ragdoll = char:Clone()
ragdoll.Name = ""
ragdoll.Humanoid.NameDisplayDistance = 0
ragdoll.Humanoid.DisplayName = ""
ragdoll.Humanoid.Health = 0
ragdoll.Humanoid.AutoJumpEnabled = false
ragdoll.Parent = game.Workspace.Map
local d = ragdoll:GetDescendants()
for i=1,#d do
local current = d[i]
if current:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
socket.Radius = 0
socket.LimitsEnabled = true
socket.UpperAngle = 30
socket.TwistLimitsEnabled = true
socket.TwistLowerAngle = -30
socket.TwistUpperAngle = 30
local jointName = current.Name
local part0 = current.Part0
local atat0 = current.Parent:FindFirstChild(jointName.. "RigAttachment")
local atat1 = part0:FindFirstChild(jointName.. "RigAttachment")
if atat0 and atat1 then
socket.Attachment0, socket.Attachment1 = atat0, atat1
socket.Parent = current.Parent
current:Destroy()
end
end
end
end
wait(1)
active = false
end
end
end)
Regular death script:
local character = script.Parent
character.Humanoid.BreakJointsOnDeath = false
character.Archivable = true
character.Humanoid.Died:Connect(function()
local d = character:GetDescendants()
for i=1,#d do
local current = d[i]
if current:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
socket.Radius = 0
socket.LimitsEnabled = true
socket.UpperAngle = 30
socket.TwistLimitsEnabled = true
socket.TwistLowerAngle = -30
socket.TwistUpperAngle = 30
local jointName = current.Name
local part0 = current.Part0
local atat0 = current.Parent:FindFirstChild(jointName.. "RigAttachment")
local atat1 = part0:FindFirstChild(jointName.. "RigAttachment")
if atat0 and atat1 then
socket.Attachment0, socket.Attachment1 = atat0, atat1
socket.Parent = current.Parent
print(current.Parent.Parent.Name.. "CoolSauce")
current:Destroy()
end
end
end
end)
EDIT: I should add that the ragdoll script is located within the knife itself, and the regular death is located within StarterCharacterScripts.