Code:
if IsParryingValue == false and IsBlockingValue == false and IsStunnedValue == false then
if Hum.MoveDirection.Magnitude == 0 then
TargetHum:TakeDamage(ConfigsModule.Configs_Punch.Damage)
coroutine.wrap(InsertKnockback)(TargetHrp, Hrp.CFrame.LookVector * ConfigsModule.Configs_Punch.Knockback.Range)
coroutine.wrap(InsertKnockback)(Hrp, Hrp.CFrame.LookVector * ConfigsModule.Configs_Punch.Knockback.Range)
elseif Hum.MoveDirection.Magnitude ~= 0 then
TargetHum:TakeDamage(ConfigsModule.Configs_Punch.Damage)
coroutine.wrap(InsertKnockback)(TargetHrp, Hrp.CFrame.LookVector * ConfigsModule.Configs_Punch.Knockback.Range)
end
TweenService:Create(TargetHrp, LookInfo, {CFrame = CFrame.lookAt(TargetHrp.Position, Hrp.Position)}):Play()
end
Knockback Function:
local function InsertKnockback(Hrp: BasePart, Direction: Vector3)
local KnockbackForce = Instance.new('BodyVelocity')
KnockbackForce.Name = 'Knockback'
KnockbackForce.Parent = Hrp
KnockbackForce.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
KnockbackForce.Velocity = Direction
task.wait(ConfigsModule.Configs_Punch.Knockback.Duration)
KnockbackForce:Destroy()
end
NOTE: I assuming that the TweenService cause the problem, but I don’t know what to do to fix it!!
How do I make this code so that when the target char rotate and look at my char and then insert knockback. But, the target char only rotate and the knockback don’t work!!