Basically I made a ragdoll script, everything works fine, except the character doesn’t want to get up…
robloxapp-20240102-0754404.wmv (2.4 MB)
Heres the code;
Server Side:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Ragdoll = ReplicatedStorage:WaitForChild("Ragdoll")
local KeyBindEvent = ReplicatedStorage:FindFirstChild("KeyBindEvent")
Players.PlayerAdded:Connect(function(player)
local PlayerFolder = Instance.new("Folder")
PlayerFolder.Name = player.UserId
PlayerFolder.Parent = ServerStorage
player.CharacterAdded:Connect(function(character)
local Debounce = false
local Humanoid = character:WaitForChild("Humanoid")
Humanoid.BreakJointsOnDeath = false
Humanoid.RequiresNeck = false
local T = character:FindFirstChild("Torso")
local H = character:FindFirstChild("Head")
local HR = character:FindFirstChild("HumanoidRootPart")
local LL = character:FindFirstChild("Left Leg")
local RL = character:FindFirstChild("Right Leg")
local LA = character:FindFirstChild("Left Arm")
local RA = character:FindFirstChild("Right Arm")
KeyBindEvent.OnServerEvent:Connect(function(player, input)
if input == " " and Debounce == false then
Ragdoll:FireClient(player, true)
Debounce = true
if T and not T:FindFirstChild("NeckJoint") then
for _,Part in ipairs(character:GetDescendants()) do
if Part:IsA("Motor6D") and Part.Name ~= "Root" and Part.Name ~= "RootJoint" then
Part.Enabled = false
end
end
local AttachmentA = Instance.new("Attachment")
AttachmentA.Parent = H
AttachmentA.Name = "NeckAttachment"
AttachmentA.Position = Vector3.new(0,-.5,0)
AttachmentA.Orientation = Vector3.new(0,0,0)
AttachmentA:SetAttribute("Ragdoll", true)
local AttachmentB = Instance.new("Attachment")
AttachmentB.Parent = T
AttachmentB.Name = "TorsoNeckAttachment"
AttachmentB.Position = Vector3.new(0,1,0)
AttachmentB.Orientation = Vector3.new(0,0,0)
AttachmentB:SetAttribute("Ragdoll", true)
local JointAB = Instance.new("BallSocketConstraint")
JointAB.Parent = T
JointAB.Name = "NeckAttachment"
JointAB.Attachment0 = AttachmentA
JointAB.Attachment1 = AttachmentB
JointAB:SetAttribute("Ragdoll", true)
local AttachmentC = Instance.new("Attachment")
AttachmentC.Parent = RA
AttachmentC.Name = "RightArmAttachment"
AttachmentC.Position = Vector3.new(-.5,.5,0)
AttachmentC.Orientation = Vector3.new(0,0,0)
AttachmentC:SetAttribute("Ragdoll", true)
local AttachmentD = Instance.new("Attachment")
AttachmentD.Parent = T
AttachmentD.Name = "TorsoRightArmAttachment"
AttachmentD.Position = Vector3.new(1,.5,0)
AttachmentD.Orientation = Vector3.new(0,0,0)
AttachmentD:SetAttribute("Ragdoll", true)
local JointCD = Instance.new("BallSocketConstraint")
JointCD.Parent = T
JointCD.Name = "RightShoulderAttachment"
JointCD.Attachment0 = AttachmentC
JointCD.Attachment1 = AttachmentD
JointCD:SetAttribute("Ragdoll", true)
local AttachmentE = Instance.new("Attachment")
AttachmentE.Parent = LA
AttachmentE.Name = "LeftArmAttachment"
AttachmentE.Position = Vector3.new(.5,.5,0)
AttachmentE.Orientation = Vector3.new(0,0,0)
AttachmentE:SetAttribute("Ragdoll", true)
local AttachmentF = Instance.new("Attachment")
AttachmentF.Parent = T
AttachmentF.Name = "TorsoLeftArmAttachment"
AttachmentF.Position = Vector3.new(-1,.5,0)
AttachmentF.Orientation = Vector3.new(0,0,0)
AttachmentF:SetAttribute("Ragdoll", true)
local JointEF = Instance.new("BallSocketConstraint")
JointEF.Parent = T
JointEF.Name = "LeftShoulderAttachment"
JointEF.Attachment0 = AttachmentE
JointEF.Attachment1 = AttachmentF
JointEF:SetAttribute("Ragdoll", true)
local AttachmentG = Instance.new("Attachment")
AttachmentG.Parent = LL
AttachmentG.Name = "LeftLegAttachment"
AttachmentG.Position = Vector3.new(0,1,0)
AttachmentG.Orientation = Vector3.new(0,0,-90)
AttachmentG:SetAttribute("Ragdoll", true)
local AttachmentH = Instance.new("Attachment")
AttachmentH.Parent = T
AttachmentH.Name = "TorsoLeftLegAttachment"
AttachmentH.Position = Vector3.new(.5,-1,0)
AttachmentH.Orientation = Vector3.new(0,0,-90)
AttachmentH:SetAttribute("Ragdoll", true)
local JointGH = Instance.new("BallSocketConstraint")
JointGH.Parent = T
JointGH.Name = "LeftHipAttachment"
JointGH.Attachment0 = AttachmentG
JointGH.Attachment1 = AttachmentH
JointGH:SetAttribute("Ragdoll", true)
local AttachmentI = Instance.new("Attachment")
AttachmentI.Parent = RL
AttachmentI.Name = "RightLegAttachment"
AttachmentI.Position = Vector3.new(0,1,0)
AttachmentI.Orientation = Vector3.new(0,0,-90)
AttachmentI:SetAttribute("Ragdoll", true)
local AttachmentJ = Instance.new("Attachment")
AttachmentJ.Parent = T
AttachmentJ.Name = "TorsoRightLegAttachment"
AttachmentJ.Position = Vector3.new(-.5,-1,0)
AttachmentJ.Orientation = Vector3.new(0,0,-90)
AttachmentJ:SetAttribute("Ragdoll", true)
local JointIJ = Instance.new("BallSocketConstraint")
JointIJ.Parent = T
JointIJ.Name = "RightHipAttachment"
JointIJ.Attachment0 = AttachmentI
JointIJ.Attachment1 = AttachmentJ
JointIJ:SetAttribute("Ragdoll", true)
HR.CanCollide = false
for i,v in ipairs(character:GetChildren()) do
if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
local Collision = Instance.new("NoCollisionConstraint")
Collision.Parent = T
Collision.Name = Collision.Name
Collision.Part0 = v
Collision.Part1 = T
Collision:SetAttribute("Ragdoll", true)
end
end
end
wait(5) --timer for the interval the player is down for
HR.CanCollide = true
for i,v in ipairs(character:GetDescendants()) do
if v:GetAttribute("Ragdoll") then
v:Destroy()
end
if v:IsA("Motor6D") then
v.Enabled = true
end
end
Ragdoll:FireClient(player, false)
Debounce = false
end
end)
end)
end)
Client Side:
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Ragdoll = ReplicatedStorage:FindFirstChild("Ragdoll")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
Ragdoll.OnClientEvent:Connect(function(RagdollStart)
if Ragdoll then
Humanoid:UnequipTools()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
StarterGui:SetCore("ResetButtonCallback", false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
else
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
StarterGui:SetCore("ResetButtonCallback", true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end)
I believe its something wrong with the state types, but I’m not sure what’s happening. (Client Side)