How to make a knockback? (both the player and the enemy goes to the same direction)

so i try to make a knockback inspired of the strongest battlegrounds, its seems that the knockback on that game goes first on the enemy and the attacker follows that direction tho, so i try to replicated, but its a little bit laggy when do it, even more when you first spawn in.

here the script of what i did:

        local Force = 100000

        local TotalForce = Force
        
        local KnockBack = Instance.new("BodyVelocity")
        KnockBack.Parent = enemy:FindFirstChild("HumanoidRootPart")

        KnockBack.MaxForce = Vector3.new(TotalForce,TotalForce,TotalForce)
        KnockBack.Velocity = player.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * velf

        local KnockBack2 = Instance.new("BodyVelocity")
        KnockBack2.Parent = player.Character:FindFirstChild("HumanoidRootPart")

        KnockBack2.MaxForce = Vector3.new(TotalForce,TotalForce,TotalForce)
        KnockBack2.Velocity = player.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * velf

        game.Debris:AddItem(KnockBack, veltime)    
        game.Debris:AddItem(KnockBack2, veltime)

(btw “veltime” and “velf” are arguments, that sets the numbers, so dont worry about them).

and a clip from the strongest battlegrounds of what im trying to replicated:

2 Likes

Use linear velocity, not body velocity.

1 Like

i try it, but only the enemy was getting knockback

forgot to put the video, silly me :nerd_face::stuck_out_tongue:

1 Like

you should parent them after you set their maxforce and velocity

emmh???, wdym by that?? like is already parent the bodyvelocities, or you mean the linear stuff?

You’re creating the instance and parenting them and then you set the properties. You should set their properties and then parent it

2 Likes

But I’m not really sure on how to fix the lag but I think you might need to do it on client or use networkowner

1 Like

Do the velocity on all the clients, would remove lag.