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: Making a NPC run away from a certain Humanoid

Previous Thread :: Next Thread 
lncrediboy is not online. lncrediboy
Joined: 17 May 2013
Total Posts: 647
17 Mar 2016 10:52 PM
Thanks to ROBLOX's STUPID update that disables negative walkspeed values I'm forced to find a substitute for NPCs running away from certain Humanoids....

Some NPCs are supposed to run away, meanwhile other NPCs chase said NPCs. They all have different Humanoid names (like instead of Humanoid, a good NPC is called simply a NPC and the other is "Crime")
I was using a zombie script.... but now since negative walkspeeds have been removed for utterly NO REASON, I need help.

I'm still a scripter in training fyi



inb4 banned or warned
Report Abuse
morash is not online. morash
Joined: 22 May 2010
Total Posts: 5834
17 Mar 2016 10:53 PM
Calculate the vector from the player to the NPC and have the NPC run along it.
Report Abuse
lncrediboy is not online. lncrediboy
Joined: 17 May 2013
Total Posts: 647
17 Mar 2016 11:01 PM
I'm so bad at scripting I can't exactly understand Vector.
Example?



inb4 banned or warned
Report Abuse
morash is not online. morash
Joined: 22 May 2010
Total Posts: 5834
17 Mar 2016 11:03 PM
A vector is essentially a direction defined with numbers. The simplest way to calculate a vector between two points is to subtract one point from another. In your case, to get the desired vector, you would subtract the position of a part in your NPC from the same part in your player.
Report Abuse
TheScripterGeek is not online. TheScripterGeek
Joined: 02 Sep 2012
Total Posts: 1192
17 Mar 2016 11:03 PM
Get the Torso of what the NPC is running away from, then add a radius of how far you want then to be, and make then continuously run in that direction at the speed of the NPC's enemy
Report Abuse
lncrediboy is not online. lncrediboy
Joined: 17 May 2013
Total Posts: 647
17 Mar 2016 11:34 PM
I have stuff like
while true do

wait(0.1)

local target = findNearestTorso(script.Parent.Torso.Position)

if target ~= nil then

script.Parent.NPC:MoveTo(target.Parent.Torso.Position, -1, -1, -1)

end

end

the MoveTo part is what I'm trying to do.
No matter what it's not working
The script I'm using is a zombie script used by other modelers...
It's just that i've modified it
local larm = script.Parent:FindFirstChild("Left Arm")

local rarm = script.Parent:FindFirstChild("Right Arm")



function findNearestTorso(pos)

local list = game.Workspace:children()

local torso = nil

local dist = 50

local temp = nil

local human = nil


local temp2 = nil

for x = 1, #list do

temp2 = list[x]

if (temp2.className == "Model") and (temp2 ~= script.Parent) then

temp = temp2:findFirstChild("Torso")

human = temp2:findFirstChild("Crime")

if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then

if (temp.Position - pos).magnitude < dist then

torso = temp

dist = (temp.Position - pos).magnitude

end

end

end

end

return torso

end



while true do

wait(0.1)

local target = findNearestTorso(script.Parent.Torso.Position)

if target ~= nil then

script.Parent.NPC:MoveTo(target.Parent.Torso.Position, -1, -1, -1)

end

end





inb4 banned or warned
Report Abuse
lncrediboy is not online. lncrediboy
Joined: 17 May 2013
Total Posts: 647
18 Mar 2016 12:46 PM
Bump...?



inb4 banned or warned
Report Abuse
lncrediboy is not online. lncrediboy
Joined: 17 May 2013
Total Posts: 647
19 Mar 2016 12:57 PM
Bump... I really want help with this!



inb4 banned or warned
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