Hello. How can I implement zombie biting. I have a script where a zombie approaches the player. I want them to bite the players and make them unable to move a little.
local function BotLogic()
Target = FindNearestPlayer(BRootPart.Position)
if not Target then
MoveToClosestPoint()
else
local TCharacter = Target.Character
local THumanoid = TCharacter and TCharacter:FindFirstChild("Humanoid")
local TRootPart = TCharacter and TCharacter:FindFirstChild("HumanoidRootPart")
if not (TRootPart and THumanoid and THumanoid.Health > 0) then
Target = nil
else
local TDistance = (BRootPart.Position - TRootPart.Position).Magnitude
if TDistance <= AttackDistance then
if BPath.Status == "Active" then
BPath:Stop()
if THumanoid and tick() - LastAttack > AttackWait then
LastAttack = tick()
THumanoid:TakeDamage(Damage)
end
end
else
local SDistance = (BRootPart.Position - BStartPosition).Magnitude
if TDistance > TargetDistance or SDistance >= StopDistance then
Target = nil
else
BPath:Run(TRootPart.Position)
end
end
end
Moving = nil
end
end
Here’s a video