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 » Scripting Helpers
Home Search
 

Re: Having trouble making an NPC "wander" around properly.

Previous Thread :: Next Thread 
sgccode9 is not online. sgccode9
Joined: 15 Dec 2007
Total Posts: 1048
28 Oct 2012 12:20 AM
I'm having a problem with a part of a script that I pulled that makes an NPC "roam" around the area its in. NOT a specific spot in the workspace but just the general area around itself.

So here's the PORTION of the script:

----------------------------------------
if time>nextrandom then
nextrandom=time+3+(math.random()*5)
local randompos=Torso.Position+((Vector3.new(1,1,1)*math.random()-Vector3.new(.5,.5,.5))*40)
Humanoid:MoveTo(randompos,game.Workspace.Terrain)
end
end
-------------------------------------------

So the problem:
The NPC walks in only TWO directions... basically back and forth in those two directions only. Like walking on a 180 degree line.

For some reason, it refuses to walk in all four directions around its space.

Its strange really, so that's what I need help with.. making it walk in all possible directions around itself rather than just two.

Any help would be appreciated, thanks! :D
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
28 Oct 2012 12:34 AM
'cause that's what u told it to do.

Try
local randompos=Torso.Position+(Vector3.new(math.random(20) - 10, math.random(20) - 10, math.random(20) - 10)

or Take NPC Wait Animation, u can set random Points as well.
Report Abuse
sgccode9 is not online. sgccode9
Joined: 15 Dec 2007
Total Posts: 1048
28 Oct 2012 12:56 AM
Tried it, they just stood still D:.

I tried removing the line I put up and inserted this instead:

Humanoid:MoveTo(Vector3.new(math.random(-500,500),0,math.random(-500,500)), game.Workspace.Base)

But they wall just wander slowly and surely to the center of the baseplate. Which I don't want to happen.. I just want them to wander in the area I PUT them. Could removing the game.workspace.Base part of the line work?
Report Abuse
sgccode9 is not online. sgccode9
Joined: 15 Dec 2007
Total Posts: 1048
28 Oct 2012 01:12 PM
HA! Got it working! Just needed to add a parenthesis ._.

Thanks.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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