So I have this code on the server when a hit is made it uses a module I have called EffectService (ES) to run my knockback effect
if game.Players:FindFirstChild(Target.Name) then --it's a player so fire to their client
--FireCharacter gets the plyer from the character
ES:FireCharacter(Target,"DefaultEffect","Knockback",Target,Player)
else --it's an an npc fire to players client
ES:FireClient(Player,"DefaultEffect","Knockback",Target,Player)
end
Effect.Knockback = function(Target,Attacker)
local PlayerLookVec = Attacker.Character.HumanoidRootPart.CFrame.LookVector
local BV = Instance.new("BodyVelocity")
BV.Name = "Knockback"
BV.MaxForce = Vector3.new(1,1,1)*5000000
BV.Velocity = Vector3.new(PlayerLookVec*50,20,0)
BV.Parent = Target.HumanoidRootPart
game.Debris:AddItem(BV,0.1)
end
And this works, however, the knockback is laggy on the attackers screen (the person not receiving the knockback) and I wanted to know what I could do to reduce the lag or if there’s a better method.
Here’s a video