I got an issue with my temporary ragdoll script (it basically creates sockets and disables motor6ds, then deletes sockets and enables motor6ds back). When player gets ragdolled, arms don’t ragdoll and animations are still playing on them.
Any help?
Can you please show a video of the issue and show yur code
wait()
local Character = game.Players.LocalPlayer.Character
local Hm = Character:WaitForChild("Humanoid")
local HmHRP = Character.HumanoidRootPart
local UIS = game:GetService("UserInputService")
local PhysicsService = game:GetService("PhysicsService")
local Ragdolling = Instance.new("BoolValue")
Ragdolling.Value = false
Ragdolling.Parent = Character
local SocketType = "BallSocketConstraint"
local RagdollKey = Enum.KeyCode.R
UIS.InputBegan:connect(function(input)
if input.KeyCode == RagdollKey then
local PlayerParts = Character:GetDescendants()
for i,M6D in pairs(PlayerParts) do
if M6D:IsA("Motor6D") then
if M6D.Name ~= "Root" then
if not M6D.Parent:FindFirstChildWhichIsA(SocketType) then
local Socket = Instance.new(SocketType)
M6D.Parent = M6D.Part1
Socket.LimitsEnabled = true
Socket.Radius = .25
Socket.TwistLimitsEnabled = true
--Socket.TwistLowerAngle = 360
--Socket.TwistUpperAngle = -180
--Socket.UpperAngle = 90
local M0,M1
if not M6D.Part0:FindFirstChild(M6D.Name .. "RigAttachment") then
print("A")
M0 = Instance.new("Attachment")
M0.Name = M6D.Name .. "RigAttachment"
M0.Parent = M6D.Part0
M0.CFrame = M6D.C0
print(M0.Name .. "A0")
end
if not M6D.Part1:FindFirstChild(M6D.Name .. "RigAttachment") then
M1 = Instance.new("Attachment")
M1.Name = M6D.Name .. "RigAttachment"
M1.Parent = M6D.Part1
M1.CFrame = M6D.C1
print(M1.Name .. "A1")
end
Socket.Parent = M6D.Parent
Socket.Attachment0 = M6D.Part0:FindFirstChild(M6D.Name .. "RigAttachment")
Socket.Attachment1 = M6D.Part1:FindFirstChild(M6D.Name .. "RigAttachment")
game.Workspace.CurrentCamera.CameraSubject = Character.Head
M6D.Enabled = false
Hm:ChangeState(Enum.HumanoidStateType.Physics)
Ragdolling = true
HmHRP.CanCollide = false
if Character:FindFirstChild("Head") then
Character.Head.CanCollide = true
end
end
end
end
end
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == RagdollKey then
local PlayerParts = Character:GetDescendants()
if Ragdolling == true then
for i,M6DBSC in pairs(PlayerParts) do
if M6DBSC:IsA(SocketType) then
M6DBSC:Destroy()
elseif M6DBSC:IsA("Motor6D") then
M6DBSC.Enabled = true
end
end
HmHRP.CFrame = HmHRP.CFrame + Vector3.new(0,2,0)
HmHRP.CanCollide = true
game.Workspace.CurrentCamera.CameraSubject = Character.Humanoid
Hm:ChangeState(Enum.HumanoidStateType.GettingUp)
if Character:FindFirstChild("Head") then
Character.Head.CanCollide = false
end
end
end
end)
That’s the code. I can’t record a video right now, but it just looks like that you got ragdolled, but your arms still got running animations (idle, walk, jump, run, climb - doesn’t matter, it just still plays).
Edit: code was not fully scripted by me, source is from unknown person.
Did you try disabling the currently playing animations? You’d need to disable the current Animate
script to avoid players from playing current walking/running animations and you’d need to run this code
for _,v in pairs(humanoid:GetPlayingAnimationTracks()) do
v:Stop(0)
end
To pause currently playing animations. Judging by your code your ragdoll is togglable, meaning you would have to set the Animate
script to Enabled
once you’re getting up.
Thanks for the reply.
I found out why does it glitch. I got custom first-person script going, and cause’ of character’s motor6ds manipulation, arms got second motor6ds (cloned ones). I edited my script so it works with custom first-person script.
Script (that I send earlier) will work, if character got no duplicated/cloned motor6ds. I would recommend to use character’s real motor6ds to avoid this kind of issues (or just make sure to disable duplicated/cloned motor6ds in your ragdoll script).