generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: NPC will never reach its target

Previous Thread :: Next Thread 
123coolz is not online. 123coolz
Joined: 29 May 2010
Total Posts: 4
06 Jun 2017 06:12 PM
local a = script.Parent.Torso.Position
repeat
print("going")
script.Parent.Humanoid:MoveTo(Vector3.new(10, 4, -142))
wait(1)
until a == (Vector3.new(10, 4, -142))

The NPC will travel to its target. Once the NPC reaches the target, it is barely off, so it will keep repeating. Is there a way to stop the repeat loop once the NPC has reached within a certain range of studs of the target?
Report Abuse
SinisterMemories is not online. SinisterMemories
Joined: 21 Mar 2013
Total Posts: 4892
06 Jun 2017 06:15 PM
magnitude

if (player.torso.Position - npc.Torso.Position).magnitude <= 12 then
then some way to break loop here?
end


#code print("oh no an errorz!")
Report Abuse
Negativize is online. Negativize
Joined: 02 May 2011
Total Posts: 25068
06 Jun 2017 06:15 PM
'then some way to break loop here?'

You mean break?
Report Abuse
SinisterMemories is not online. SinisterMemories
Joined: 21 Mar 2013
Total Posts: 4892
06 Jun 2017 06:17 PM
yes


#code print("oh no an errorz!")
Report Abuse
RottenWraith is not online. RottenWraith
Joined: 16 Aug 2008
Total Posts: 1587
06 Jun 2017 06:28 PM
If the problem is that the NPC is off of the target location by a few decimal points, math.ceil might fix your issue
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image