-
What do you want to achieve?
I made a relatively basic ragdoll system that I designed to be toggleable on/off whenever I need to (my game has many scenarios which needs a brief ragdoll state toggle) -
What is the issue?
The ragdolled character seems fine on the client, but for all other clients the torso seems misplaced.
When the player dies, however, the ragdoll replicates perfectly. -
What solutions have you tried so far?
I’ve tried changing the network owner for all the parts in the character to server when it’s ragdolled, but that introduced a handful of new issues and it looked very choppy on the client.
All the joints are pre-made and are simply enabled/disabled when needed.
Serverside:
function PlayerModule.PlayerHandler:ToggleRagdoll(enabled)
local char = self.Player.Character
char.Humanoid.RequiresNeck = not enabled
events.Ragdoll:FireClient(self.Player, enabled)
char.Torso.RagdollWeld.Enabled = enabled
for i,part in pairs(char.Torso:GetChildren()) do
if part:IsA("BallSocketConstraint") then
part.Enabled = enabled
elseif part:IsA("Motor6D") then
part.Enabled = not enabled
end
end
end
Clientside:
Resources.Events.Ragdoll.OnClientEvent:Connect(function(enabled)
if Resources.Character then
if enabled then
runservice:BindToRenderStep("LockMouse", Enum.RenderPriority.Last.Value+1, function()
inputservice.MouseBehavior = Enum.MouseBehavior.LockCenter
end)
Resources.MouseLocked = true
Resources.Player.CameraMaxZoomDistance = 6
Resources.Player.CameraMode = Enum.CameraMode.Classic
Resources.Player.CameraMinZoomDistance = 6
Resources.Character:WaitForChild("Humanoid"):ChangeState(Enum.HumanoidStateType.Physics)
Resources.Humanoid.AutoRotate = false
else
Resources.Player.CameraMode = Enum.CameraMode.LockFirstPerson
Resources.Player.CameraMinZoomDistance = 0.5
Resources.Player.CameraMaxZoomDistance = 0.5 -- TODO: CHANGE THIS
Resources.Character:WaitForChild("Humanoid"):ChangeState(Enum.HumanoidStateType.GettingUp)
Resources.Character.Humanoid.AutoRotate = true
end
Resources.Character:WaitForChild("CollidePart").CanCollide = not enabled
FirstPerson.Ragdoll = enabled
end
if not enabled and Resources.MouseLocked then
Resources.MouseLocked = false
runservice:UnbindFromRenderStep("LockMouse")
end
end)