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!
i believe this has something to do with humanoid state type, you can force the character into something else, i think what your’s is happening is that the server think that you landed and made the humanoid state type one, i might be wrong
I found it myself. If you are having the same problem then you can try whenever the player gets up from ragdolling, have it to raycast from above the player pointing to the ground for as much lenght as you want. Then you can use a function that i think is called :GetExtendsSize() to the players Character model to basicly get the model size. After you get the model size teleport the character to the position that the ray hitted plus you add the model size Y vector / 2 to the position Y vector.(If the ray didnt hit anything then the player most likely is not at the ground so dont teleport it) This is a really rough explanation of what i did and it worked. If you have any questions feel free to ask me.
i have the same issue here and try to do what you saying, but idk gives me error everytime i try to code it.
here the part of the script what im doing if you asking:
local char = script.Parent
local HRP = char:WaitForChild("HumanoidRootPart")
local size = char:GetExtentsSize()
local rayOrigin = HRP.Position
local rayDirection = Vector3.new(0, -100, 0)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {script.Parent}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycastResult then
local platform = raycastResult.Instance
HRP.Position = platform.Position + size.Y/2
else
end
local Char = script.Parent
local bv = Instance.new("BoolValue")
bv.Name = "Ragdoll"
bv.Parent = Char
In LocalScript(Client)
local Char = script.Parent
local hrp = Char:WaitForChild("HumanoidRootPart")
local hum = Char:WaitForChild("Humanoid")
local is_ragdolling = Char:WaitForChild("Ragdoll") -- ragdoll boolean so you know when to snap out of it
local function reorient()
local cf = hrp.CFrame
local lv = cf.LookVector
if math.abs(lv:Dot(Vector3.yAxis)) > 0.95 then
lv = -cf.UpVector
end
hrp.CFrame = CFrame.lookAlong(
cf.Position,
Vector3.new(lv.X, 0, lv.Z),
Vector3.yAxis
)
hum:ChangeState(Enum.HumanoidStateType.GettingUp)
end
hum.StateChanged:Connect(function(from, to)
if (to==Enum.HumanoidStateType.FallingDown or to==Enum.HumanoidStateType.Physics) and not is_ragdolling.Value then
task.wait()
reorient()
end
end)
is_ragdolling.Changed:Connect(function(b)
if b==false then
task.wait()
reorient()
end
end)