Ragdoll script issue

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I am currently making a game where players are hit with a weapon. When hit, players are flung and ragdoll. The game is set to r15

  1. What is the issue? Include screenshots / videos if possible!

The issue here is that at times, the player will randomly die and or vanish when they hit the floor and re-appear and I believe the issue is the ragdoll script.

Thereā€™s another issue where the character being ragdolled flops arounds on the ground. Iā€™d like it to be a smooth ragdoll like in Slap Battles and then the player unragdolls. I am not sure if the issue is with R15 rigs.

I am not a good scripter, so please dont hate on me lol.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Iā€™ve tried looking into module scripts posted on devforum; however, Iā€™ve had no luck due to being new to developing.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that itā€™s easier for people to help you!

The ragdoll script is located within the weapon and is activated through a function within the hithandler (flings the player on hit)

Here is the ragdoll script below:

local humanoid = script.Parent.Parent:WaitForChild(ā€˜Humanoidā€™)

humanoid.BreakJointsOnDeath = false
humanoid.RequiresNeck = false

wait(0.01)
for index,joint in pairs(script.Parent.Parent:GetDescendants()) do
if joint:IsA(ā€˜Motor6Dā€™) then
local socket = Instance.new(ā€˜BallSocketConstraintā€™)
local a1 = Instance.new(ā€˜Attachmentā€™)
local a2 = Instance.new(ā€˜Attachmentā€™)
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.c0
a2.CFrame = joint.c1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint:Destroy()

	end

end
wait(1.5)
for i, v in pairs(script.Parent.Parent:GetDescendants()) do
if v:IsA(ā€œBallSocketConstraintā€) then

	v.UpperAngle = 0
	v.TwistUpperAngle = 0
	v.TwistLowerAngle = 0
	local Joins = Instance.new("Motor6D", v.Parent)
	Joins.Part0 = v.Attachment0.Parent
	Joins.Part1 = v.Attachment1.Parent
	Joins.C0 = v.Attachment0.CFrame
	Joins.C1 = v.Attachment1.CFrame
	v:Destroy()
end

end
script.Parent:Destroy()

2 Likes

You should probably format your script correctly using the quadruple ā€œ````ā€

--Your script will look more readable like this.

However, to address your problem, you may want to look into module scripts posted by other scripters online. These scripts are to make yourā€¦ scripting experience easier, by making simple-to-use functions that can be passed at any time.

However, this code for me worked perfectly fine (If not a bit broken)
Server script in StarterCharacterScripts:

local humanoid: Humanoid = script.Parent:WaitForChild("Humanoid")

humanoid.BreakJointsOnDeath = false
humanoid.RequiresNeck = false

task.wait(3)

local motors = {}


humanoid.PlatformStand = true
for index,joint in pairs(script.Parent:GetDescendants()) do
	if joint:IsA("Motor6D") then
		local socket = Instance.new("BallSocketConstraint")
		local a1 = Instance.new("Attachment")
		local a2 = Instance.new("Attachment")
		a1.Parent = joint.Part0
		a2.Parent = joint.Part1
		socket.Parent = joint.Parent
		socket.Attachment0 = a1
		socket.Attachment1 = a2
		a1.CFrame = joint.C0
		a2.CFrame = joint.C1
		socket.LimitsEnabled = true
		socket.TwistLimitsEnabled = true

		table.insert(motors, joint)
		joint.Enabled = false
	end
end

task.wait(2)

for i, v in ipairs(motors) do
	v.Enabled = true
end
humanoid.PlatformStand = false
humanoid.Jump = true

Remember: You can utilize parts of this code for your ragdoll system, but I dont think you can just slap this into your game. Also, I wouldnt recommend using script.Parent:Destroy() because you might want your code to run more than once.

2 Likes