Hello Dev forum, It’s been awhile since I been here so please correct me If anything I’ve do or say in this post is wrong, or rule Violating.
Recently, my friends and I started working on a small project. The game involves attacking people with pans. also including a badge hunting and a few quest (game is a work in progress right now) Everything was going well into we struck into a problem with one of our pvp mechanics
The issue/Dilemma that’s happening is when the player Damages a person with a frying pan, there supposed to ragdoll upon the damage taken, but the script that we wrote isn’t working and not ragdolling them upon the damage whatsoever. here’s the code for the script. (we put this in the serverscriptservice)
local function applyRagdollAndKnockback(player, damageAmount)
local humanoid = player.Character:FindFirstChild("Humanoid")
if humanoid then
humanoid.BreakJointsOnDeath = false
humanoid.Died:Connect(function()
for _, joint in pairs(humanoid:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.CFrame = joint.C0
a2.CFrame = joint.C1
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint.Enabled = false
end
end
humanoid.RootPart.CanCollide = false
end)
end
local knockbackForce = Vector3.new(0, 0, -damageAmount)
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = knockbackForce * 100
bodyVelocity.Parent = player.Character.HumanoidRootPart
game:GetService("Debris"):AddItem(bodyVelocity, 0.5)
end
If Someone Could correct us this script or help us it will be greatly appreciated,