apologies if the title made no sense, here’s a longer description of my problem. So I have a part that ragdolls players when they touch it, it works properly when it’s just placed in the workspace but when I use code to clone the part and place it where player is, the ragdoll stops working and gives me this error: FireClient: player argument must be a Player object
here’s the module script that errors:
local RagdollFunctions = {}
RagdollFunctions.Ragdoll = function(random, char, player) -- this line errors
game.ReplicatedStorage.RagdollEvent: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
if v:IsA("BasePart") and v.Name == "Head" or v:IsA("BasePart") and v.Name == "LowerTorso" 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
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 appreciated!