I’m trying to make a combat system where you kick someone they get ragdolled and get flung back. The system works perfectly fine for rigs and npc’s but when I hit another player, they stand still like nothing happened. I do not know why this is happening and I am confused. I am a bit unfamiliar with the systems I am working with in the code so any help would be appreciated on why this is happening.
local DAMAGE = 10
local INTERVAL = 1/0.5
local debounce = {}
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= nil and hit.Name == "HumanoidRootPart" then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local LocalChar = script.Parent.Parent.Parent
if LocalChar.RShoe.Hitbox.IsActive.Value == true then
local character = hit.Parent
if not debounce[hit.Parent.Name] or os.time() - debounce[hit.Parent.Name] >= 1 then
debounce[hit.Parent.Name] = os.time()
script.Parent.Sound:Play()
humanoid:TakeDamage(DAMAGE)
humanoid.BreakJointsOnDeath = false
local HumanoidRootPart = hit
local pushForce = 550
local lookVector = character.HumanoidRootPart.CFrame.LookVector
local upwardForce = Vector3.new(0, 600, 0)
local totalForce = (script.Parent.Parent.Parent.HumanoidRootPart.CFrame.LookVector * pushForce) + upwardForce
character.HumanoidRootPart:ApplyImpulse(totalForce)
for _, v in pairs(humanoid.Parent:GetDescendants()) do
if v:IsA("Motor6D") then
local Attachment0, Attachment1 = Instance.new("Attachment"), Instance.new("Attachment")
Attachment0.CFrame = v.C0
Attachment1.CFrame = v.C1
Attachment0.Parent = v.Part0
Attachment1.Parent = v.Part1
local BSC = Instance.new("BallSocketConstraint")
BSC.Attachment0 = Attachment0
BSC.Attachment1 = Attachment1
BSC.Parent = v.Parent
v:Destroy()
elseif v.Name ~= "HumanoidRootPart" and v.Name ~= "Torso" and v.Name ~= "Head" and v.Name == "Left Arm" or v.Name == "Right Arm" or v.Name == "Left Leg" or v.Name == "Right Leg" then
humanoid.PlatformStand = true
if character:FindFirstChild("RArm") and character:FindFirstChild("RLeg") and character:FindFirstChild("LLeg") and character:FindFirstChild("LArm") then
character.RArm.CanCollide = true
character.RLeg.CanCollide = true
character.LArm.CanCollide = true
character.LLeg.CanCollide = true
wait(1)
character.RArm.CanCollide = false
character.RLeg.CanCollide = false
character.LArm.CanCollide = false
character.LLeg.CanCollide = false
humanoid.PlatformStand = false
end
end
end
for _, v in pairs(humanoid.Parent:GetDescendants()) do
if v:IsA("BallSocketConstraint") then
v.UpperAngle = 0
v.TwistUpperAngle = 0
v.TwistLowerAngle = 0
local Joints = Instance.new("Motor6D",v.Parent)
Joints.Part0 = v.Attachment0.Parent
Joints.Part1 = v.Attachment1.Parent
Joints.C0 = v.Attachment0.CFrame
Joints.C1 = v.Attachment1.CFrame
v:Destroy()
wait(0.1)
if game.Players:FindFirstChild(hit.Parent.Name) then
local Player = game:GetService("Players")
local player = Player[hit.Parent.Name]
game.ReplicatedStorage.Events.ToClient.GettingUp:FireClient(player, humanoid)
end
end
end
end
end
end
task.wait(INTERVAL)
end)
The script runs in a part that’s in an accessory that’s in the player’s character.
Character
Accessory
Part
Script