The script inside the player, and the script inside the NPCs are identical
When an NPC gets ragdolled it works perfectly, but when a player gets ragdolled they float above the ground?
It was working perfectly before the update last night.
Here is a video showing the issue.
Here is hierarchy
(This is in StarterCharacterScripts)
Here is the ragdoll script (Identical to NPC)
local globals = require(game.ReplicatedStorage:WaitForChild("Modules"):WaitForChild("Globals"))
--------------------
local RagdolledVal = script:WaitForChild("Ragdolled")
local CanRagdoll = script:WaitForChild("CanRagdoll")
local Humanoid = script.Parent:FindFirstChildWhichIsA("Humanoid")
local HumanoidRootPart: BasePart = Humanoid.RootPart
local ragJointsCreated = false
local ogCC
local ogOwner
if Humanoid then
Humanoid.RequiresNeck = false
Humanoid.BreakJointsOnDeath = false
RagdolledVal.Changed:Connect(function()
if RagdolledVal.Value == true then
if CanRagdoll.Value then
ogCC = HumanoidRootPart.CanCollide
ogOwner = HumanoidRootPart:GetNetworkOwnershipAuto() or HumanoidRootPart:GetNetworkOwner()
HumanoidRootPart:SetNetworkOwner(nil)
HumanoidRootPart:SetNetworkOwnershipAuto(false)
HumanoidRootPart.CanCollide = true
Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
local animator = globals.getAnimator(Humanoid) -- Gets the animator, no effect on script
if animator then
local anims = animator:GetPlayingAnimationTracks()
for _, a in pairs(anims) do
a:Stop()
end
end
if not ragJointsCreated then
for _, motor: Motor6D in pairs(script.Parent:GetDescendants()) do
if motor:IsA("Motor6D") then
motor.Enabled = false
local newBSC = Instance.new("BallSocketConstraint", motor.Parent)
local a0 = Instance.new("Attachment", motor.Part0)
local a1 = Instance.new("Attachment", motor.Part1)
a0.CFrame = motor.C0
a1.CFrame = motor.C1
newBSC.Attachment0 = a0
newBSC.Attachment1 = a1
newBSC.Name = motor.Name .. ":RagdollConstraint"
newBSC.LimitsEnabled = true
newBSC.TwistLimitsEnabled = true
newBSC.Enabled = true
end
end
ragJointsCreated = true
else
for _, motor: Motor6D in pairs(script.Parent:GetDescendants()) do
if motor:IsA("Motor6D") then
local BSC = motor.Parent:FindFirstChild(motor.Name .. ":RagdollConstraint")
BSC.Enabled = true
motor.Enabled = false
end
end
end
else
RagdolledVal.Value = false
end
else
if CanRagdoll.Value then
HumanoidRootPart.CanCollide = ogCC
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
for _, motor: Motor6D in pairs(script.Parent:GetDescendants()) do
if motor:IsA("Motor6D") then
local BSC = motor.Parent:FindFirstChild(motor.Name .. ":RagdollConstraint")
if BSC then
BSC.Enabled = false
motor.Enabled = true
end
end
end
if HumanoidRootPart.Parent and HumanoidRootPart.Parent:IsDescendantOf(game.Workspace) then
if ogOwner == true then
HumanoidRootPart:SetNetworkOwnershipAuto()
else
HumanoidRootPart:SetNetworkOwner(ogOwner)
end
end
end
end
end)
end
and this is the ragdoll function inside ‘globals’
function globals.setRagdolled(Humanoid : Humanoid, Ragdolled : boolean)
if Ragdolled == nil then
Ragdolled = not Ragdolled
ragdollStates[Humanoid] = not ragdollStates[Humanoid]
else
ragdollStates[Humanoid] = Ragdolled
end
local RagdollScript = Humanoid.Parent:FindFirstChild("Ragdoll")
if RagdollScript then
RagdollScript.Ragdolled.Value = Ragdolled
end
end
I’ve tried different state types, different network owners, I have no idea what’s wrong as it was working before the update