I am trying to create an active ragdoll like in GTA and Red Dead Redemption but the legs keep clipping through the ground even though that cancollide is enabled on every body part. How can I fix this?
External Media
1 Like
I think Roblox automatically turn off CanCollide even if you set it with a script.
Run in test and check the properties in the Server window (not the Client window).
I have a great ragdoll module I found if you would like to look it over for pointers.
In Server and Client Cancollide is on.
Sure, can you share the module.
I don’t remember where I found this ragdoll script.
SCRIPT:
-- VARIABLES
local debounce = false -- delay
local module = require(game.ReplicatedStorage.RagdollScript) -- module script variable
local defense = game.Workspace:WaitForChild("Defense")
-- ACTIVATE RAGDOLL SCRIPT
defense.Touched:Connect(function(hit)
if debounce == false then
if hit.Parent:FindFirstChild("Humanoid") then
debounce = true
local char = hit.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(char)
module:Ragdoll(char, player) -- turn on ragdoll
wait(4) -- time ragdolled
module:Stand(char, player, char.Humanoid) -- turn off ragdoll
wait(2)
debounce = false
end
end
end)
MODULE:
local RagdollFunctions = {}
-- RAGDOLL PLAYER
RagdollFunctions.Ragdoll = function(random, char, player) -- ragdoll function
game.ReplicatedStorage.Ragdoll:FireClient(player, "Ragdoll") -- fire an event to the client
char.Humanoid.JumpPower = 0 -- make sure they cant jump
for _, v in pairs(char:GetDescendants()) do
-- weld head to torso
if v:IsA("BasePart") and v.Name == "Head" then
local weld = Instance.new("Weld")
weld.Part0 = char.HumanoidRootPart
weld.Part1 = v
weld.C0 = char.HumanoidRootPart.CFrame:inverse()
weld.C1 = v.CFrame:Inverse()
weld.Parent = char.HumanoidRootPart
end
--clone parts and set to collide
local clonePart = char:FindFirstChild("RagdollClones")
if not clonePart then
local part = game.ReplicatedStorage.RagdollClones:Clone()
part.Parent = char
for _, v in pairs(char:GetDescendants()) do
if v:IsA("BasePart") and v.Name == "LeftFoot" then
local weld = Instance.new("Weld")
weld.Part0 = char.LeftFoot
weld.Part1 = v
weld.C0 = char.LeftFoot.CFrame:inverse()
weld.C1 = v.CFrame:Inverse()
weld.Parent = char.LeftFoot
local left = v:Clone()
left.Parent = char.RagdollClones
left.CanCollide = true
char.RagdollClones.LeftFoot.Transparency = 1
end
if v:IsA("BasePart") and v.Name == "RightFoot" then
local weld = Instance.new("Weld")
weld.Part0 = char.RightFoot
weld.Part1 = v
weld.C0 = char.RightFoot.CFrame:inverse()
weld.C1 = v.CFrame:Inverse()
weld.Parent = char.RightFoot
local left = v:Clone()
left.Parent = char.RagdollClones
left.CanCollide = true
char.RagdollClones.RightFoot.Transparency = 1
end
if v:IsA("BasePart") and v.Name == "LeftHand" then
local weld = Instance.new("Weld")
weld.Part0 = char.LeftHand
weld.Part1 = v
weld.C0 = char.LeftHand.CFrame:inverse()
weld.C1 = v.CFrame:Inverse()
weld.Parent = char.LeftHand
local left = v:Clone()
left.Parent = char.RagdollClones
left.CanCollide = true
char.RagdollClones.LeftHand.Transparency = 1
end
if v:IsA("BasePart") and v.Name == "RightHand" then
local weld = Instance.new("Weld")
weld.Part0 = char.RightHand
weld.Part1 = v
weld.C0 = char.RightHand.CFrame:inverse()
weld.C1 = v.CFrame:Inverse()
weld.Parent = char.RightHand
local left = v:Clone()
left.Parent = char.RagdollClones
left.CanCollide = true
char.RagdollClones.RightHand.Transparency = 1
end
end
end
-- create new joints
if v:IsA("Motor6D") then
local attachment1 = Instance.new("Attachment")
local attachment0 = Instance.new("Attachment")
attachment0.Name = "Attachment0"
attachment1.Name = "Attachment1"
attachment0.CFrame = v.C0
attachment1.CFrame = v.C1
attachment0.Parent = v.Part0
attachment1.Parent = v.Part1
local contraint = Instance.new("HingeConstraint") -- change to BallSocket if you want
contraint.Attachment0 = attachment0
contraint.Attachment1 = attachment1
contraint.Parent = v.Parent
v:Destroy()
char.Humanoid.PlatformStand = true -- char will not fall down without this setting
end
end
end
-- RETURN PLAYER TO STANDING
RagdollFunctions.Stand = function(random, char, player, humanoid) -- standing function
char.Humanoid.JumpPower = 50
-- destroy hinges amd turn off platform stand
for _, v in pairs(char:GetDescendants()) do
if v.Name == "Attachment0" or v.Name == "Attachment1" or v:IsA("Weld") or v:IsA("HingeConstraint") then -- change HingeConstraint to BallSocket if that is what you chose earlier
v:Destroy()
char.Humanoid.PlatformStand = false
end
end
-- destroy clones
for _, v in pairs(char:GetDescendants()) do
if v:IsA("Model") and v.Name == "RagdollClones" then
v:Destroy()
end
end
-- rebuild joints
humanoid:BuildRigFromAttachments()
game.ReplicatedStorage.Ragdoll:FireClient(player, "Stand") -- fire the standing event to thw client
end
return RagdollFunctions
The RagdollClones is an empty model.
1 Like
Thanks, I just made a part the same size as the foot and welded it.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.