You should probably use LinearVelocity with magnitude set to 400 for best acceleration physics and the velocity to anything you’d like. Don’t forget to set “RelativeTo” to Attachment0
It just does this now.
Also, the movement is kind of robotic, in my opinion.
Script:
local npc = script.Parent
local hrpOfNPC = npc:WaitForChild("HumanoidRootPart")
local plrsHit = {}
local maxDistance = math.huge
local function applyForce(hrp)
local dir = (hrp.Position - hrpOfNPC.Position).Unit
hrpOfNPC.LinearVelocity.VectorVelocity = dir * 5
end
npc.Humanoid.Touched:Connect(function(touch)
if game.Players:GetPlayerFromCharacter(touch.Parent) and not plrsHit[game.Players:GetPlayerFromCharacter(touch.Parent)] then
plrsHit[game.Players:GetPlayerFromCharacter(touch.Parent)] = true
touch.Parent.Humanoid:TakeDamage(100)
wait(1)
plrsHit[game.Players:GetPlayerFromCharacter(touch.Parent)] = false
end
end)
while wait() do
local plrs = game.Players:GetPlayers()
local closestHRP
for i, plr in pairs(plrs) do
if plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") and plr.Character.Humanoid.Health > 0 then
local hrp = plr.Character.HumanoidRootPart
local distanceBetween = (hrpOfNPC.Position - hrp.Position).Magnitude
if not closestHRP then closestHRP = hrp end
if (hrpOfNPC.Position - closestHRP.Position).Magnitude > distanceBetween then
closestHRP = hrp
end
end
end
if closestHRP and (hrpOfNPC.Position - closestHRP.Position).Magnitude <= maxDistance then applyForce(closestHRP) end
end
I am actually going to hit the hay at this moment, so replies are gonna either be tomorrow, or soon.