You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I want to stop my characters from occasionally freezing in the air.
What is the issue? I am using this ragdoll module to ragdoll my character when I die. Currently, from time to time, the player randomly freezes in mid-air instead of ragdoll-ing.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked for ragdoll alternatives, but the others also had their own issues. I also looked for people having the same issues as me, I had no luck. At first I thought that it was because my character walked into a vertical kill brick [I am in an obby game], but, upon further investigation, I found that dying again after that without walking into any vertical kill brick also presented that same issue until after a few deaths it resolves itself.
The script, only modified for the death event but here:
local PhysicsService = game:GetService("PhysicsService")
local module = require(script.ModuleScript)
local ragParts = script.RagdollParts:GetChildren()
local r6Client = script.R6RagdollClient
PhysicsService:CreateCollisionGroup("Ragdoll")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local humanoid = char.Humanoid
char.Head.Size = Vector3.new(1, 1, 1)
humanoid.BreakJointsOnDeath = false
humanoid.RequiresNeck = false
local clones = {}
for _, v in ipairs(ragParts) do
clones[v.Name] = v:Clone()
end
local folder1 = Instance.new("Folder")
folder1.Name = "RagdollConstraints"
for _, v in pairs(clones) do
if v:IsA("Attachment") then
v.Parent = char[v:GetAttribute("Parent")]
elseif v:IsA("BallSocketConstraint") then
v.Attachment0 = clones[v:GetAttribute("0")]
v.Attachment1 = clones[v:GetAttribute("1")]
v.Parent = folder1
end
end
folder1.Parent = char
local folder2 = Instance.new("Folder")
folder2.Name = "Motors"
local value
for _, v in ipairs(char.Torso:GetChildren()) do
if v:IsA("Motor6D") then
value = Instance.new("ObjectValue")
value.Value = v
value.Parent = folder2
end
end
folder2.Parent = folder1
humanoid.Died:Connect(function()
module:Ragdoll(char)
end)
r6Client:Clone().Parent = char
end)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
--//Services
local Players = game:GetService("Players")
local PhysicsService = game:GetService("PhysicsService")
PhysicsService:CreateCollisionGroup("Ragdoll")
--//Modules
local module = require(script.ModuleScript)
--//Variables
local ragParts = script.RagdollParts:GetChildren()
local r6Client = script.R6RagdollClient
--//Functions
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local humanoid = char.Humanoid
humanoid.BreakJointsOnDeath = false
humanoid.RequiresNeck = false
module:Setup(char)
humanoid.Died:Connect(function()
module:Ragdoll(char)
end)
char.Head.Size = Vector3.one
local clones = {}
for _, v in ipairs(ragParts) do
clones[v.Name] = v:Clone()
end
local folder1 = Instance.new("Folder")
folder1.Name = "RagdollConstraints"
for _, v in pairs(clones) do
if v:IsA("Attachment") then
v.Parent = char[v:GetAttribute("Parent")]
elseif v:IsA("BallSocketConstraint") then
v.Attachment0 = clones[v:GetAttribute("0")]
v.Attachment1 = clones[v:GetAttribute("1")]
v.Parent = folder1
end
end
folder1.Parent = char
local folder2 = Instance.new("Folder")
folder2.Name = "Motors"
local value = nil
for _, v in ipairs(char.Torso:GetChildren()) do
if v:IsA("Motor6D") then
value = Instance.new("ObjectValue")
value.Value = v
value.Parent = folder2
end
end
folder2.Parent = folder1
r6Client:Clone().Parent = char
end)
end)
You forgot to include RagdollModule:Setup(character).
I have no clue why you have the other code, but if it’s not needed, then you can just delete it.
Is the other code below needed then?
If you’re using a custom module I don’t see why you would need it. I’ll check out the module more and I’ll reply back though.
Ohhh I got this completely confused, my apologies. I just realized that it’s the base code for it because it sets up everything.
--[[
Place this script in ServerScriptService
For instructions on how to use, refer to the devforum post:
https://devforum.roblox.com/t/smooth-r6-ragdoll-for-players-and-npcs-plug-and-play
]]
local PhysicsService = game:GetService("PhysicsService")
local module = require(script.ModuleScript)
local ragParts = script.RagdollParts:GetChildren()
local r6Client = script.R6RagdollClient
PhysicsService:CreateCollisionGroup("Ragdoll")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local Humanoid = char:WaitForChild("Humanoid")
Humanoid.Died:Connect(function()
char.RagdollTrigger.Value = true
end)
-- Setup ragdoll
local humanoid = char.Humanoid
char.Head.Size = Vector3.new(1, 1, 1)
humanoid.BreakJointsOnDeath = false
humanoid.RequiresNeck = false
local clones = {}
for _, v in ipairs(ragParts) do
clones[v.Name] = v:Clone()
end
local folder1 = Instance.new("Folder")
folder1.Name = "RagdollConstraints"
for _, v in pairs(clones) do
if v:IsA("Attachment") then
v.Parent = char[v:GetAttribute("Parent")]
elseif v:IsA("BallSocketConstraint") then
v.Attachment0 = clones[v:GetAttribute("0")]
v.Attachment1 = clones[v:GetAttribute("1")]
v.Parent = folder1
end
end
folder1.Parent = char
local folder2 = Instance.new("Folder")
folder2.Name = "Motors"
local value
for _, v in ipairs(char.Torso:GetChildren()) do
if v:IsA("Motor6D") then
value = Instance.new("ObjectValue")
value.Value = v
value.Parent = folder2
end
end
folder2.Parent = folder1
-- Ragdoll trigger
local trigger = Instance.new("BoolValue")
trigger.Name = "RagdollTrigger"
trigger.Parent = char
trigger.Changed:Connect(function(bool)
if bool then
module:Ragdoll(char)
else
module:Unragdoll(char)
end
end)
r6Client:Clone().Parent = char
end)
end)
(You can remove the comments, I just copied this from the post and changed a bit)
Switching the RagdollTrigger to true works better than :Ragdoll for some reason. It’s probably due to the fact there are some checks on the client for it.
Alright I will try this right now.
I forgot to mention, upon freezing, if the player doesn’t fall off the map, the ragdoll eventually does work in about 6-10 seconds. This is obviously not practical.
I find it strange how big a difference changing the BoolValue’s value was as opposed to directly calling the method. I have since not been able to replicate my issue. Thanks!
I did some more digging and it’s because there is a client script that applies the impulse for the character only when the bool value is changed. It’s just poor module design.
I have kill bricks, sometimes running or just landing onto them results in freezing. It may be a delay in the motor6ds and ballsocketconstraints enabling/disabling as the frozen character eventually does ragdoll. To answer your question, it doesn’t happen every time but when it does, it recurs consecutively.
I tried setting the players health to 0, changing its state to dead, and temporarily making the kill brick can collide false if its not already. I do this on the client.
I’m on mobile right now, I won’t be on pc till tomorrow. The script consists of collectionservice listening for instances with the ‘instakills’ tagto be added. On touching the part, if the part’s parent is the player’s character then the player’s character dies and the cancollide of the kill part is toggled twice with a task.wait() in between.