i’ve been trying to find the cure to ragdoll lag and only one thing stands in my way: motor6d’s breaking it for some reason. the videos demonstrate this. the first one shows when the character dies, their network ownership is immediately reset to the player instead of the server, BreakJointsOnDeath is turned OFF. it results in absolutely no lag, which would be perfect for a ragdoll:
this second video shows when the motor6d’s ARE disabled. BreakJointsOnDeath is STILL OFF, the motor6d’s are just being disabled when the player dies. as shown clearly in the video there’s like a half second of just freeze before it gets smooth again.
does anyone know why this happens, or if there’s a way to make a ragdoll without disabling/destroying motor6d’s? any thoughts are very very appreciated!!
code used for demonstation:
(server script)
local Players = game:GetService("Players")
local RagdollModule = require(script.Ragdoll)
-- Hook player character death
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
humanoid.BreakJointsOnDeath = false
humanoid.Died:Connect(function()
RagdollModule:RagdollChar(char)
local prompt = Instance.new("ProximityPrompt")
--prompt.Parent = char
end)
end)
end)
(ragdoll module [DISABLING MOTORS])
local Players = game:GetService("Players")
local Ragdoll = {}
function Ragdoll:RagdollChar(character)
if not character then return end
local player = Players:GetPlayerFromCharacter(character)
if not player then return end
for _, part in ipairs(character:GetDescendants()) do
if part:IsA("BasePart") then
part:SetNetworkOwner(player)
end
if part:IsA("Motor6D") then
part:Destroy()
end --REMOVE THIS BLOCK FOR SMOOTH DEATH
end
end
return Ragdoll
chrono was disabled for this. its behavior is different when its turned on, it doesn’t replicate correctly the charracter glitches into the ground and stuff.
Setting the network owner to the player will double the amount of network lag to every other player for the ragdoll effect. Is it necessary to do this?
If it’s still an issue, try disabling them instead of destroying them; destroying is known to cause lag spikes with large amounts of instances, but maybe this is adding some extra lag somehow.
Finally, if that doesn’t work, you could always try running it on the client. Either watch for deaths on the client or have a RemoteEvent that’s triggered whenever someone dies that gives the dying player. Then it’s just a matter of disabling the Motors on the client. You might get some non-deterministic physics oddities, but it won’t need to network anything.