Im to make a NPC which holds guns and shoots, but it will stay at a distance. How do I take the torso (which the gun holder is gonna move to) position and subtract the position with -5,0,0?
(this is the script)
hue = script.Parent.Torso
while wait(1) do
for i, v in pairs(workspace:GetChildren()) do
if v:IsA("Model") then
z=v:FindFirstChild("ishuman")
if z then
for i, b in pairs(z.Parent:GetChildren()) do
if b:IsA("Model") then
if b.Name == v.Name then
z1 = b:FindFirstChild("Torso")
if (z1.Position - hue.Position).magnitude <= 20 then
script.Parent.Humanoid:MoveTo() -- the players torsos position with Z posotion subtracted by 5
end
end
end
end
end
end
end
end

2 comments
Post your code in the NPC?
I have a script similar to this. basically, what mine does it stops the script when it's in a 5 stud radius. I achieved this by using the loop while pos > 5 do