-
What do you want to achieve? A ragdoll script that ragdolls whoever touched the part
-
What is the issue? in my module script that handles the RagdollFunctions I get an error that says
Expected BasePart got WrapTarget for Weld:Part1.
when I try to weld the head and lower torso to the humanoidRootPart. -
What solutions have you tried so far? I’ve looked at the wrap target API yet it didn’t provide any possible solutions.
here’s the module script:
local RagdollFunctions = {}
RagdollFunctions.Ragdoll = function(random, char, player) -- ragdoll function
game.ReplicatedStorage.RagdollEvent:FireClient(player, "Ragdoll") -- fire an event to the client
char.Humanoid.JumpPower = 0
for _, v in pairs(char:GetDescendants()) do
if v:IsA("BasePart") and v.Name == "Head" or v.Name == "LowerTorso" then
local weld = Instance.new("Weld")
weld.Part0 = char.HumanoidRootPart
weld.Part1 = v -- part where it errors
weld.C0 = char.HumanoidRootPart.CFrame:Inverse()
weld.C1 = v.CFrame:Inverse()
weld.Parent = char.HumanoidRootPart
end
if v:IsA("Motor6D") then
local attachment0 = Instance.new("Attachment")
local attachment1 = 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 constraint = Instance.new("HingeConstraint")
constraint.Attachment0 = attachment0
constraint.Attachment1 = attachment1
constraint.Parent = v.Part0
v:Destroy()
end
end
end
RagdollFunctions.Stand = function(random, char, player, humanoid) -- standing function
humanoid.JumpPower = 50
for _, v in pairs(char:GetDescendants()) do
if v.Name == "Attachment0" or v.Name == "Attachment1" or v:IsA("Weld") or v:IsA("HingeConstraint") then
v:Destroy()
end
end
humanoid:BuildRigFromAttachments() -- very handy function
game.ReplicatedStorage.RagdollEvent:FireClient(player, "Stand")
end
return RagdollFunctions
all help is greatly appreciated