I’m trying to add a ragdoll effect that stops once the victim’s body has landed and then waits a second before waking up. (using only this single script too + trying to make the rig fully can collide when ragdolled so parts collide on the floor and not into each other.)
This hasn’t worked perfectly because on non player rigs it works good (excluding the collide bit which idk how I can do that) and on player rigs the rig just hangs from the HumanoidRootPart of it’s character instead of hit the ground.
I know this is because of how you can’t set player rigs network owner to the server due to some security but I really need an alternative (and maybe a way to make it so these parts don’t anti collide into each other’s body parts)
Code:
d=false
canhit=false
anims = {}
function tempragdoll(player,character)
character.PrimaryPart:SetNetworkOwner(nil)
character.Humanoid.BreakJointsOnDeath = false
character.Humanoid.RequiresNeck = false
character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
for _, v in pairs(character:GetDescendants()) do --ragdoll
if v:IsA("Motor6D") then
local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
a0.CFrame = v.C0
a1.CFrame = v.C1
a0.Parent = v.Part0
a1.Parent = v.Part1
local b = Instance.new("BallSocketConstraint")
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = v.Part0
v.Enabled = false
end
end
task.wait(script.Parent.Power.Value/15)
for _,v in pairs(character:GetDescendants()) do --unragdoll
if v:IsA('Motor6D') then
v.Enabled = true
end
if v.Name == 'BallSocketConstraint' then
v:Destroy()
end
if v.Name == 'Attachment' then
v:Destroy()
end
end
character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
character.Humanoid.BreakJointsOnDeath = false
character.Humanoid.RequiresNeck = false
if player ~= nil then character.PrimaryPart:SetNetworkOwner(player) end
end
script.Parent.Parent.Activated:Connect(function()
if not d and script.Parent.Parent.Parent.Humanoid:GetState() ~= (Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.Dead) then
d=true
canhit=true
local player = script.Parent.Parent.Parent
if anims[player.Name] == nil then
anims[player.Name] = {slap = player.Humanoid:LoadAnimation(script.Parent.slap),}
end
anims[player.Name].slap:Stop()
anims[player.Name].slap:Play()
local alreadyhit = {}
script.Parent.Parent.Unequipped:Connect(function()
d=false
canhit=false
return
end)
script.Parent.Union.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")~=nil and hit.Parent~= player and table.find(alreadyhit,hit.Parent)==nil and canhit then
table.insert(alreadyhit,hit.Parent)
local p = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent).Character
local ve = Instance.new("LinearVelocity",hit.Parent:FindFirstChild("HumanoidRootPart"))
local a1 = Instance.new("Attachment",hit.Parent:FindFirstChild("HumanoidRootPart"))
local a2 = Instance.new("Attachment",hit.Parent:FindFirstChild("HumanoidRootPart"))
ve.MaxForce = math.huge
ve.Attachment0 = a1
ve.Attachment1 = a2
ve.VectorVelocity = (p:FindFirstChild("HumanoidRootPart").CFrame.LookVector * script.Parent.Power.Value) + Vector3.new(0,script.Parent.Power.Value,0)
game.Debris:AddItem(ve,0.25)
game.Debris:AddItem(a1,0.25)
game.Debris:AddItem(a2,0.25)
script.Parent.Slap.TimePosition = 0.2 script.Parent.Slap:Play() script.Parent.Slap2:Play()
tempragdoll(game.Players:GetPlayerFromCharacter(hit.Parent),hit.Parent)
end
end)
anims[player.Name].slap.Stopped:Wait()
canhit=false
task.wait(script.Parent.Cooldown.Value)
d=false
end
end)
Here’s some pictures of examples about the different between non-player rigs and player rigs:
NPC:

Player:

Any help is appreciated!