You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Im doing a ragdoll script using ragdoll state, and the new joints upgrade
-
What is the issue? but it doesnt work completely as the player keeps trying to get up while falling, which causes annoyance like sudden shaking and bugs, while physic state does work better, when on the ground it just start trying to get up somehow
-
What solutions have you tried so far? Other states like platform standing, only ragdoll state seems to work , others will cause no fall damage registration or weird behavior
local disabledStates = {
Enum.HumanoidStateType.Ragdoll,
Enum.HumanoidStateType.FallingDown,
Enum.HumanoidStateType.Freefall,
Enum.HumanoidStateType.Dead,
Enum.HumanoidStateType.Physics,
}
local character = script.Parent :: Model
local humanoid = script.Parent.Humanoid :: Humanoid
-- keep BallSocketConstraints on death
humanoid.BreakJointsOnDeath = false
-- avoid HRP colliding with UpperTorso on death
character.HumanoidRootPart.CanCollide = false
function changeJ(T)
if T < 7000 then
for _, joint in character:GetDescendants() do
if joint:IsA("AnimationConstraint") then
joint.Enabled = true
joint.MaxTorque = T
elseif joint:IsA("BallSocketConstraint") then
joint.MaxFrictionTorque = 10
end
end
else
--humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
for _, joint in character:GetDescendants() do
if joint:IsA("AnimationConstraint") then
joint.Enabled = true
joint.MaxTorque = T
elseif joint:IsA("BallSocketConstraint") then
joint.MaxFrictionTorque = 0
end
end
end
end
torque = 7000
humanoid.Died:Connect(function()
print("died!")
for _, joint in character:GetDescendants() do
if joint:IsA("AnimationConstraint") then
joint.Enabled = false
joint.MaxTorque = 0
torque = 0
elseif joint:IsA("BallSocketConstraint") then
joint.MaxFrictionTorque = 10
end
end
end)
-- hack: if we don't wait, the joints get disabled and the arms get stuck in a weird position
task.wait(1)
local stfall = tick()
while humanoid.Health > 0 do
local enableAC = true
local state = humanoid:GetState()
if table.find(disabledStates, state) then
enableAC = false
else
stfall = tick()
end
if tick() - stfall > 0.5 and humanoid.Health > 0 and character.HumanoidRootPart.AssemblyLinearVelocity.Magnitude > 4 then
humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
--humanoid.PlatformStanding = true
torque = 0
print("RAGDOLL")
else
--humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
if state == Enum.HumanoidStateType.Ragdoll and character.HumanoidRootPart.AssemblyLinearVelocity.Magnitude < 4 then
torque = math.clamp(torque + 10,0,8000)
humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
--humanoid.PlatformStanding = true
changeJ(torque)
--print(torque)
else
end
for _,j in character:GetDescendants() do
if j:IsA("AnimationConstraint") and j.Name ~= "Root" then
j.Enabled = enableAC
end
end
game["Run Service"].RenderStepped:Wait()
end