--SCRIPT 1
pirate = script.Parent
while wait() do
for i,v in next, workspace:GetChildren() do
if game.Players:GetPlayerFromCharacter(v) then
plr = v
if (pirate.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 50 then
pirate.Humanoid:MoveTo(v.HumanoidRootPart.Position)
pirate:WaitForChild("Value").Value = true
else
pirate:WaitForChild("Value").Value = false
end
end
end
end
second script
--SCRIPT 2
local pirate = script.Parent
local hum = pirate.Humanoid
local lidle = script.idle
local ljump = script.jump
local lrun = script.run
local lfall = script.fall
idle = hum:LoadAnimation(lidle)
jump = hum:LoadAnimation(ljump)
run = hum:LoadAnimation(lrun)
fall = hum:LoadAnimation(lfall)
idle:Play()
hum.Running:Connect(function(speed)
if speed > 1 then
if pirate:WaitForChild("Value").Value then
idle:Stop()
repeat run:Play() wait(0.95) until speed < 1
elseif speed < 1 then
run:Stop()
idle:Play()
end
end
end)
while wait() do
if not pirate:WaitForChild("Value").Value then
run:Stop()
idle:Play()
end
end
when the npc touches the player, the animation becomes very glitchy and gets spammed, any way to prevent that?
