So I use a series of methods to create a ragdoll, such as BallSocketConstraints (to connect the player’s body parts), :ChangeState(Enum.HumanoidStateType.Physics) [to simulate it looking like a ragdoll], and the disabling/enabling of Motor6Ds. However, only the person who is being ragdolled can see the ragdoll so I have to use :FireAllClients() so other clients can see the ragdoll. But the bad thing is that the event fires correctly, but the ragdoll from other clients.
How do I fix this or create a better method instead of using :FireAllClients()?
local RemoteEvent = game.ReplicatedStorage.FallMechanic.CommitRagdoll
RemoteEvent.OnClientEvent:Connect(function(character, getUp)
if not getUp then
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") then
v.Enabled = false
end
end
character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
elseif getUp == true then
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") then
v.Enabled = true
end
end
character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end)
(getUp is a variable of either true/false so if getUp is false, then it will ragdoll. if getUp is true, the ragdoll will get back up)
You’re disabling the Motor6D on the client, not the server. That’s why it shows frozen for other players, and not you.
Easy fix to this is to disable the Motor6D’s on the server-side.
I’m not 100% on how to solve that. I think it just depends on the player’s connection or something.
Also you don’t need to :ChangeState() if you’re trying to kill the player, you can just set their health to 0 via game.Workspace.EXAMPLENAME.Health = 0
in my game, there’s no ragdolling upon death, i just use :ChangeState(Enum.HumanoidStateType.Physics) to simulate the ragdoll when they take fall damage
Alright. So a little fun fact about the way Motor6D’s work, when a player dies, Roblox automatically removes all Motor6D’s in that player’s character. You don’t need to change anything as a matter of fact if you’re killing the player.
However if you’re disabling the player’s movement for a while, try to set the Motor6D’s to disabled (Which you already did) or store the Motor6D’s in a separate parent temporarily.
Plus constraints already do the physics stuff for you, so if you need to change the humanoid’s state something isn’t working right.
EDIT
Even if the player is stuck on the ground, you don’t have to change their state. You can disable PlatformStand or Sit.
well without :ChangeState(), it looks like this (in the gyazo link) and you can still control your character… at least it doesn’t freeze though! : D
i think with :ChangeState() would be better so you can’t control your character and it looks more like a ragdoll. i don’t know how to fix the freeze though