Hello there!
I made a ragdoll script where it make you go ragdoll and then in some seconds later it makes you go to normal.
The thing is that i faced a problem of whenever the player gets up from ragdolling it is flinging like this:
I also added when the player is ragdolling HipHeight = 0, PlatformStand = true, AutoRotate = false and walkspeed, jumppower to 0.(all of this values turn back to normal when the player gets back to normal aswell)
Here the script that is on the server:
local CurrHipHeight = nil
function Ragdoll(eCharacter)
for i, v in pairs(eCharacter:GetChildren()) do
for _, v2 in pairs(v:GetChildren()) do
if v2:IsA("Motor6D") and v2.Parent.Name ~= "HumanoidRootPart" and v2.Parent.Name ~= "Head" and v2.Parent.Name ~= "RightHand" and v2.Parent.Name ~= "LeftHand" and v2.Parent.Name ~= "RightFoot" and v2.Parent.Name ~= "LeftFoot" then
local Socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
eCharacterForRagdoll = eCharacter
a1.Parent = v2.Part0
a2.Parent = v2.Part1
Socket.Parent = v2.Parent
Socket.Attachment0 = a1
Socket.Attachment1 = a2
a1.CFrame = v2.C0
a2.CFrame = v2.C1
Socket.LimitsEnabled = true
Socket.TwistLimitsEnabled = true
v2:Destroy()
end
end
end
CurrHipHeight = eCharacter.Humanoid.HipHeight
eCharacter.Humanoid.HipHeight = 0
eCharacter.Humanoid.AutoRotate = false
eCharacter.Humanoid.PlatformStand = true
eCharacter.Humanoid.WalkSpeed = 0
eCharacter.Humanoid.JumpPower = 0
end
function UnRagdoll()
local eCharacter = eCharacterForRagdoll
if eCharacterForRagdoll ~= nil and eCharacter ~= nil and eCharacter.Humanoid.Health ~= 0 then
for i, v in pairs(eCharacter:GetDescendants()) do
if v:IsA("BallSocketConstraint") then
v.UpperAngle = 0
v.TwistUpperAngle = 0
v.TwistLowerAngle = 0
local Joins = Instance.new("Motor6D", v.Parent)
Joins.Part0 = v.Attachment0.Parent
Joins.Part1 = v.Attachment1.Parent
Joins.C0 = v.Attachment0.CFrame
Joins.C1 = v.Attachment1.CFrame
v:Destroy()
wait()
end
end
eCharacter.Humanoid.HipHeight = CurrHipHeight
eCharacter.Humanoid.AutoRotate = true
eCharacter.Humanoid.PlatformStand = false
eCharacter.Humanoid.WalkSpeed = 16
eCharacter.Humanoid.JumpPower = 50
eCharacterForRagdoll = nil
end
end
local AttackEvent = game.ReplicatedStorage.CombatSystem.RemoteEvents.Attack
AttackEvent.OnServerEvent:Connect(function(player, Event, Character)
if Event == "Ragdoll" then
Ragdoll(Character)
elseif Event == "Unragdoll" then
UnRagdoll()
end
end)
Player presses R to send a server remote to ragdoll and when the player let goes the R key then it fires again a server remote to go back to normal
Is there any way to fix this?
Any suggestion will be appreciated!