Im trying to fix an event-based ragdoll script that has been in my game for a long time.
whenever the player gets ragdolled, as long as they hold the jump button they are able to position their ragdolled character upright and start flying into the air. This continues until the ragdolling stops.
Ive tried to use the Humanoid state type “physics” yet it doesnt do anything. Ive also tried enabling platformstand. My last resort is setting the humanoids jumppower to 0, but not even that solved my issue.
local PS = game:GetService("PhysicsService")
game.ServerStorage.EquinoxEngineAssets.Ragdoll.Event:Connect(function(char, ragdolltime)
if char.Name == "" then --things i dont want to be ragdolled
return
else
local collidearms = char.RagdollClient.CollideArms
local collidelegs = char.RagdollClient.CollideLegs
if collidelegs.Disabled==true then
local ws = char.Humanoid.WalkSpeed
local jp = char.Humanoid.JumpPower
local permjp=jp
char.Humanoid.JumpPower=0
char.Humanoid.RequiresNeck=false
char.Humanoid.BreakJointsOnDeath=false
local player = game.Players:FindFirstChild(char.Name)
for i,v in pairs(char:GetDescendants()) do
if v:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = v.Part0
a2.Parent = v.Part1
socket.Parent = v.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = v.C0
a2.CFrame = v.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
socket.MaxFrictionTorque = 15
socket.UpperAngle = 0.5
v.Enabled = false
end
end
local up=game.ServerStorage.EquinoxEngineAssets.standUp:Clone()
game.Debris:AddItem(up, 2)
collidearms.Disabled = false
collidelegs.Disabled = false
char:FindFirstChild("HumanoidRootPart").CanCollide=false
if char:FindFirstChild("HumanoidRootPart") and char.HumanoidRootPart:FindFirstChild("RootJoint") and char.HumanoidRootPart.RootJoint.Enabled == false then
char:FindFirstChild("HumanoidRootPart").RootJoint.Enabled = true
end
char.Humanoid.AutoRotate = false
task.wait(ragdolltime)
for i,v in pairs(char:GetDescendants()) do
if v:IsA("BallSocketConstraint") then
v:Destroy()
end
if v:IsA("Motor6D") then
v.Enabled = true
end
end
local down=game.ServerStorage.EquinoxEngineAssets.standDown:Clone()
game.Debris:AddItem(down, 2)
if char.Humanoid.WalkSpeed == ws then
char.Humanoid.WalkSpeed = ws
end
if char.Humanoid.JumpPower == 0 then
char.Humanoid.JumpPower = permjp
end
local getup = script.GettingUp:Clone()
getup.Parent = char
getup.Disabled = true
game.Debris:AddItem(getup, 2)
collidearms.Disabled = true
collidelegs.Disabled = true
char.Humanoid.AutoRotate = true
char.HumanoidRootPart.Orientation=Vector3.new(0,0,0)
end
end
end)
standUp and standDown are localscripts that set the physics statetype for the humanoid, before anyone asks.
thanks!
edit: it turns out the character doesnt start to fly upward because of jumping (sorta)
jumping just positions the character upright, but its the fact that its upright that causes it to fly. As long as the character is upright, it doesnt matter if they are jumping or not, they will start flying into the air. They have to be mid-air for them to start flying, if they are on the ground then they arent going to start flying.
robloxapp-20230420-2301431.wmv (3.5 MB)