i'm having a problem with my zombie. i haven't really ever successfully made a zombie before, this is my first time. pretty much what this zombie does is it walks around its spawn point, and when it roams too far away, it walks back to its spawn point. when a player comes near it, it follows the player. the problem im having is that the zombie makes a jerking, or twitching motion which is not in it's animation while walking towards the player. example

script inside of the zombie:

local zombie = script.Parent.Parent
local anim = zombie.Animation
local hum = zombie.Humanoid
local animtrack = hum:LoadAnimation(anim)
local Distance = 30
local target = nil
local anim_Playing = false
wait(3)

function Roam()
	animtrack:Play()
	hum:MoveTo(zombie.UpperTorso.Position + Vector3.new(math.random(-5,5),0,math.random(-5,5)))
	hum.MoveToFinished:Wait(2)
	if (zombie.UpperTorso.Position - game.Workspace.Spawn.Position).magnitude > 30 then
		local path = game:GetService("PathfindingService"):ComputeRawPathAsync(zombie.UpperTorso.Position, game.Workspace.Spawn.Position + Vector3.new(math.random(-2,2),0,math.random(-2,2)), 200)
		local points = path:GetPointCoordinates()
		if anim_Playing == false then
		animtrack:Play()
		anim_Playing = true
		end
		for p = 1, #points do
			hum:MoveTo(points[p])
			hum.MoveToFinished:Wait()
		end
	end
end


while wait() do
	for i,v in pairs (game.Players:GetChildren()) do
		local plr_Distance = (v.Character.UpperTorso.Position - zombie.UpperTorso.Position).magnitude
		if plr_Distance <= Distance then
			local plrpath = game:GetService("PathfindingService"):ComputeRawPathAsync(zombie.UpperTorso.Position, v.Character.UpperTorso.Position, Distance)
			local plrpoints = plrpath:GetPointCoordinates()
			for p = 1, #plrpoints do
				wait(.1)
				hum:MoveTo(plrpoints[p])
			end
			if plr_Distance <= 3 then
				wait(1)
				if plr_Distance <=3 then
					v.Character.Humanoid.Health = v.Character.Humanoid.Health - 20
				end
			end
		else
			Roam()
		end
	end
end



2 comments

0

i have the same with a nps, u can put the scripts off and still he puts his arm up when some one get close. so that means its not in the script but some where else. im gonna changer from npc and look for one in toolbox that dont dose that and add my own script to the new npc. thats the tip i can give u

0

some npc's like the guest of roblox self have that in them and i dont know where to find it. had every thing checked in the npc but still couldnt find it. so i gues it put some how in them so it will always be there