Calling function from module script throws error

im trying to call a function from a module script called ragdoll but i have this error:
image

script:

--kill plr + ragdoll
local ragdollMod = require(script.ragdollModule)

ragdollMod.ragdoll()
char.Humanoid.Health = 0

module:

local ragdollModule = {}
local char = game.Players.LocalPlayer.Character
local Humanoid = char:WaitForChild("Humanoid")
Humanoid.BreakJointsOnDeath = false

function ragdollModule.ragdoll()
Humanoid.Died:Connect(function()
	for index, joint in pairs(char: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
end)
end
1 Like

i fixed the problem, i sent the LOCAL players character to the server which is wrong. had to send it to a local script!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.