I am making a game were you are using guns (those are working no problem) and swords to fight slime monsters. But the problem is that I would like to make the swords knock the enemies back on impact so that the sword becomes more reliable to use!
Here is the script I attempted to use:
door = script.Parent
function onTouch(hit)
if hit.Parent == nil then return end
local h = hit.Parent:FindFirstChild("Zombie")
if h ~= nil then
hit.Parent.Torso.Velocity=door.CFrame.lookVector * -100
end
door.Touched:connect(onTouch)
It only works when the enemy is standing still, when they move it no longer works. How can I resolve this issue? (I am also doing this in a filtering enabled game) If you can help me out with this, I would be more than happy! Thanks!
