can anyone tell me how to make a better ragdoll that, when you get unragdoll have no issue by jumping or spinning around, just getting up and stand or by literaly teleporting in the air gen raycast by getting the floor and cframe on it, just wait to the floor if disenabled if youre too close to there, im making a combat system inspired by other games, and ofc tsb so you get what im getting into by saying “better ragdoll”
i use boolvalue for enabled and here is the script and using pre-made “ballsocketcontraint” inside of the script
local char = script.Parent
local fx = char:WaitForChild("Values").NormalVals.Ragdoll
local hum = char:WaitForChild("Humanoid")
local HRP = char:WaitForChild("HumanoidRootPart")
local run = game:GetService("RunService")
local torso = char:WaitForChild("Torso")
local plr = game:GetService("Players"):GetPlayerFromCharacter(char)
local size = char:GetExtentsSize()
function getup ()
local sockets = {}
local parts = {}
local weldsparts = {}
for _,v in pairs(char:GetDescendants()) do
char.Humanoid.Sit = false
if v:IsA("Motor6D") then
v.Enabled = true
elseif v.Name == "RagdollSocket" then
table.insert(sockets,v)
elseif v.Name == "RagdollSocket0" then
table.insert(sockets,v)
elseif v.Name == "RagdollPat" then
table.insert(parts,v)
elseif v.Name == "ragpartjoin" then
table.insert(weldsparts,v)
elseif v.Parent.Name == "RagdollJoints" then
v.Enabled = false
end
end
for _,v in pairs(sockets) do
v:Destroy()
end
for _,v in pairs(parts) do
v:Destroy()
end
for _,v in pairs(weldsparts) do
v:Destroy()
end
hum.PlatformStand = false
hum.Sit = false
HRP.CanCollide = true
HRP.Massless = false
hum.JumpPower = 50
hum.WalkSpeed = 16
hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
hum:ChangeState(Enum.HumanoidStateType.GettingUp)
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)
--script.Getorphysics:FireAllClients(plr, "getup")
if raycastResult then
local platform = raycastResult.Instance
HRP.CFrame = CFrame.lookAt(raycastResult.Position, raycastResult.Position + raycastResult.Normal + Vector3.new(HRP.Position.X, size.Y/2, HRP.Position.Z))
else
hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
end
end
function ragdolledf ()
hum.JumpPower = 0
hum.WalkSpeed = 0
hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
hum:ChangeState(Enum.HumanoidStateType.Physics)
for _,v in pairs(char:GetChildren()) do
if v:IsA("Part") then
if v.Name == "Torso" or v.Name == "Right Leg" or v.Name == "Right Arm" or v.Name == "Left Leg" or v.Name == "Left Arm" then
local ragdollsparts = Instance.new("Part", v)
ragdollsparts.Size = Vector3.new(1, 0.972, 1)
ragdollsparts.Anchored = false
ragdollsparts.Massless = true
ragdollsparts.CanTouch = false
ragdollsparts.CanCollide = true
ragdollsparts.Transparency = 1
ragdollsparts.Name = "RagdollPat"
local weldd = Instance.new("Weld", v)
weldd.Part0 = v
weldd.Part1 = ragdollsparts
weldd.Name = "ragpartjoin"
end
end
end
for _,v in pairs(char:GetDescendants()) do
if v:IsA("Motor6D") then
char.Humanoid.Sit = true
if v.Name ~= "Root" and v.Name ~= "RootJoint" and v.Name ~= "joinpart" and v.Name ~= "joinhitbox" and v.Name ~= "ragpartjoin" then
local att0 = Instance.new("Attachment")
att0.Name = "RagdollSocket0"
att0.CFrame = v.C0
att0.Parent = v.Part0
local att1 = Instance.new("Attachment")
att1.Name = "RagdollSocket"
att1.CFrame = v.C1
att1.Parent = v.Part1
local socket = script.RagdollJoints:FindFirstChild(v.Name)
socket.Attachment0 = att0
socket.Attachment1 = att1
socket.Enabled = true
v.Enabled = false
end
end
end
HRP.CanCollide = false
HRP.Massless = true
end
fx.Changed:Connect(function()
if fx.Value == true then
ragdolledf()
elseif fx.Value == false then
getup()
end
end)