hello there! I just figured out how to set players into ragdoll but I ran into a problem when implementing it into a script. So basically the player types the spell (ad somnum) in the chat and presses on a player which causes them to go into ragdoll for like 5 seconds. The player chatting and clicking on a player is handled in a local script and the rest is handled in a server script. The script works fine but the ragdoll only makes them wiggle but they dont drop.
here’s an example of what happens:
https://gyazo.com/2a8adc5f8021e531415e5619ed7dd00e
here’s the server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BurnEvent = ReplicatedStorage.Remotes:WaitForChild("Sleep")
BurnEvent.OnServerEvent:Connect(function(player, target)
local victim = target.Parent:FindFirstChild("Humanoid")
local victimCharacter = target.Parent
if victim then
victim.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
victim.Parent.Humanoid.JumpPower = 0
for _, v in pairs(victim.Parent:GetDescendants()) do
if v:IsA("BasePart") and v.Name == "Head" or v.Name == "LowerTorso" then
local weld = Instance.new("Weld")
weld.Part0 = victim.Parent.HumanoidRootPart
weld.Part1 = v
weld.C0 = victim.Parent.HumanoidRootPart.CFrame:Inverse()
weld.C1 = v.CFrame:Inverse()
weld.Parent = victim.Parent.HumanoidRootPart
end
if v:IsA("Motor6D") then
local attachment1 = Instance.new("Attachment")
local attachment0 = Instance.new("Attachment")
attachment1.Name = "Attachment1"
attachment0.Name = "Attachment0"
attachment0.CFrame = v.C0
attachment1.CFrame = v.C1
attachment0.Parent = v.Part0
attachment1.Parent = v.Part1
local constraint = Instance.new("BallSocketConstraint")
constraint.Attachment1 = attachment1
constraint.Attachment0 = attachment0
constraint.Parent = v.Part0
v:Destroy()
end
end
local bv = Instance.new("BodyVelocity")
bv.Velocity = target.Parent.HumanoidRootPart.CFrame.LookVector * -2
bv.Parent = target
wait(0.1)
bv:Destroy()
for count = 1,10 do
wait()
player.Character.Magic.Value -= 7.5
end
wait(50)
target.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
target.Parent.Humanoid.JumpPower = 50
for _, v in pairs(target.Parent:GetDescendants()) do
if v.Name == "Attachment1" or v.Name == "Attachment0" or v:IsA("Weld") or v:IsA("BallSocketConstraint") then
v:Destroy()
end
end
target.Parent.Humanoid:BuildRigFromAttachments()
end
end)