|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 18 Mar 2016 12:46 PM |
Bump...?
inb4 banned or warned |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2016 12:57 PM |
Bump... I really want help with this!
inb4 banned or warned |
|
|
| Report Abuse |
|
|