-
I want to achieve a knockback that knocks the victim back in the direction of the attacker’s humanoid facing.
-
Everything works and the body velocity gets instanced but after that nothing happens. Like if the body velocity is not working
-
I have tried putting it in the torso instead of the humanoidRootPart but nothing changed
by the way, the players are r6. Not sure if that changes anything at all but just letting you all know.
all script
remote.OnServerEvent:Connect(function(plr, player)
player.canDamage.Value = true
if player.canDamage.Value == true then
player.canDamage.Value = false
local event; event = player.Character["Right Leg"].Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(10)
local anination = Instance.new("Animation")
anination.AnimationId = "rbxassetid://6885472391"
local anim = humanoid:LoadAnimation(anination)
anim:Play()
local knockback = Instance.new("BodyVelocity")
knockback.MaxForce = Vector3.new(1,0,1) * 3000
knockback.Velocity = humanoid.Parent.HumanoidRootPart.CFrame.lookVector * 100
knockback.Parent = humanoid.Parent.HumanoidRootPart
wait(1)
knockback:Destroy()
player.canDamage.Value = false
event:Disconnect()
else
event:Disconnect()
end
end)
end
end)
BodyVelocity Part of script
local knockback = Instance.new("BodyVelocity")
knockback.MaxForce = Vector3.new(1,0,1) * 3000
knockback.Velocity = humanoid.Parent.HumanoidRootPart.CFrame.lookVector * 100
knockback.Parent = humanoid.Parent.HumanoidRootPart
wait(1)
knockback:Destroy()
player.canDamage.Value = false
event:Disconnect()
else
event:Disconnect()
end
end)
end
end)