Hi my names Pixeluted and I want do NPC if player near then NPC run away but I want do Position But I got error
while wait() do
local Players = game.Players:GetChildren()
for _,player in pairs(Players) do
local PlayerCharacter = workspace:FindFirstChild(player.Name)
if PlayerCharacter then
if (PlayerCharacter.HumanoidRootPart.Position - script.Parent.HumanoidRootPart.Position).Magnitude <= 15 then
local PositionMove = Vector3.new(PlayerCharacter.HumanoidRootPart.Position.X,PlayerCharacter.HumanoidRootPart.Position.Y,PlayerCharacter.HumanoidRootPart.Position.Z - Vector3.new(0,0,-6))
print(PositionMove)
end
else
print("Character Dont Founded")
end
end
end
Also, for future reference, please read the error more carefully to see that you gave it the wrong kind of value / data type (Z(number) - Vector when expected a number)
Also also, player.Character should be used instead.
I really don’t see the point in
Vector3.new(LONGX, LONGY, LONGZ-Vecto3…) anyway, just use
pos - Vector3.new(0,0,6) or something
Also try to use variables more so it is easier to read