I making a script that ragdoll player,
When disabling ragdoll sometimes character fling to air.
How can i stop that?
-- Disable ragdoll and restore original Motor6D states
local function disableRagdoll(player,motors)
if player and motors then
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
if character:FindFirstChild("RagdollParts") then
character:FindFirstChild("RagdollParts"):Destroy()
end
for _,v in pairs(character:GetDescendants()) do
if v:IsA('Motor6D') then
v.Enabled = true
end
if v.Name == 'BallSocketConstraint' then
v:Destroy()
end
if v.Name == 'Attachment' then
v:Destroy()
end
end
humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
player:SetAttribute("Ragdoll",false)
local currentPivot = character:GetPivot()
character:PivotTo(currentPivot + Vector3.new(0,5,0))
humanoid.PlatformStand = false
humanoid.AutoRotate = true
end
end