Hey guys it’s agKing here and today I have a problem with hitting a player so when I KO a player in Roblox it makes the ragdoll effect applies to me and that’s a very annoying issue so here’s the code of the effect
Events.ThrowPunch.OnServerEvent:Connect(function(player)
if player then
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")
local rootPart = character:FindFirstChild("HumanoidRootPart")
local Head = character:FindFirstChild("Head")
local RightLowerArm = character:FindFirstChild("RightLowerArm")
local LeftLowerArm = character:FindFirstChild("LeftLowerArm")
RightLowerArm.Touched:Connect(function(hit)
local playerTouched = game.Players:GetPlayerFromCharacter(hit.Parent)
if playerTouched and playerTouched ~= player then
local character = playerTouched.Character
local humanoid = character:FindFirstChild("Humanoid")
local rootPart = character:FindFirstChild("HumanoidRootPart")
if humanoid and rootPart then
RagdollJoints:SetupJoints(character, humanoid)
local function DoRagdoll()
humanoid.AutoRotate = false
for _, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") and v.Name ~= "Waist" and v.Name ~= "Root" then
v.Enabled = false
end
end
if humanoid.RigType == Enum.HumanoidRigType.R15 then
for _, part in pairs(character:GetChildren()) do
if part:IsA("BasePart") then
part.CanCollide = true
end
end
end
force = Instance.new("BodyVelocity")
force.MaxForce = Vector3.new(100000, 100000, 100000) -- Max force
force.Velocity = Vector3.new(0, -5, 0) -- Apply downward force
force.Parent = rootPart
game:GetService("Debris"):AddItem(force, 4)
wait(4)
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") then
v.Enabled = true
end
end
humanoid.AutoRotate = true
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
end
DoRagdoll()
end
end
end)
LeftLowerArm.Touched:Connect(function(hit)
local playerTouched = game.Players:GetPlayerFromCharacter(hit.Parent)
if playerTouched and playerTouched ~= player then
local character = playerTouched.Character
local humanoid = character:FindFirstChild("Humanoid")
local rootPart = character:FindFirstChild("HumanoidRootPart")
if humanoid and rootPart then
RagdollJoints:SetupJoints(character, humanoid)
local function DoRagdoll()
humanoid.AutoRotate = false
for _, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") and v.Name ~= "Waist" and v.Name ~= "Root" then
v.Enabled = false
end
end
if humanoid.RigType == Enum.HumanoidRigType.R15 then
for _, part in pairs(character:GetChildren()) do
if part:IsA("BasePart") then
part.CanCollide = true
end
end
end
force = Instance.new("BodyVelocity")
force.MaxForce = Vector3.new(100000, 100000, 100000) -- Max force
force.Velocity = Vector3.new(0, -5, 0) -- Apply downward force
force.Parent = rootPart
game:GetService("Debris"):AddItem(force, 4)
wait(4)
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") then
v.Enabled = true
end
end
humanoid.AutoRotate = true
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
end
DoRagdoll()
end
end
end)
end
end)
I tried using Connection = on the touched event but this made the effect stop working I think the issue lies that event if the event hasn’t triggered on the server side such as LocalPlayer clicked to land a hit on a player the .Touched event still is getting trigger in the remote event tho the RemoteEvent from the other player haven’t executed the LowerArm.Touched event detect that whatever a touch has been made the player should ragdoll too which is not normal is there an issue to this problem ?