of     1   

RealistK
#140968171Sunday, July 20, 2014 6:36 PM GMT

So when you get near a monster and then you run out of their maxdistance, they are supposed to walk back, but what they do is: You suddenly control them, if you press up they go down, if you press left they go right. Weird.. how do I fix it that they just walk back to their original position? Value with distance and a value with maxdistance in the script. local larm = script.Parent:FindFirstChild("Left Arm") local rarm = script.Parent:FindFirstChild("Right Arm") maxdist = script.MaxDistance.Value start = script.Parent.Torso.Position function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = script.Distance.Value 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("Humanoid") 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) newdist = script.Parent.Torso.Position dist = newdist - start print(dist) if dist.x -maxdist and dist.z -maxdist then if target ~= nil then script.Parent["Enemy"]:MoveTo(target.Position, target) end else script.Parent["Enemy"]:MoveTo(start) end end
PalmToFace
#140968580Sunday, July 20, 2014 6:40 PM GMT

Humanoid:MoveTo()
RealistK
#140968807Sunday, July 20, 2014 6:42 PM GMT

It's a RPG enemy he, the name is Enemy of the humanoid.
RealistK
#140974040Sunday, July 20, 2014 7:39 PM GMT

meep
RealistK
#140981725Sunday, July 20, 2014 9:06 PM GMT

bump
RealistK
#140992154Sunday, July 20, 2014 10:55 PM GMT

bump
bibo5o
#140992383Sunday, July 20, 2014 10:58 PM GMT

Sorry real, I don't think people are ignoring this, they probably just don't understand what's going on.
Notunknown99
#140994760Sunday, July 20, 2014 11:22 PM GMT

if dist.x -maxdist and dist.z -maxdist then if (dist.x*dist.x + dist.z*dist.z) < maxdist*maxdist then --a^2 + b^2 == c^2, like magnitude but fasterer.
Origin_Sea
#140994936Sunday, July 20, 2014 11:24 PM GMT

I think people just don't want to read bulk scripts.
Notunknown99
#140995404Sunday, July 20, 2014 11:29 PM GMT

script.Parent["Enemy"]:MoveTo(target.Position, target) Try removing the ", target".
RealistK
#141041366Monday, July 21, 2014 9:05 AM GMT

Removing target didn't work. :s The weirdest part is that it works fine in play solo, but it doesn't work in the actual server.
Origin_Sea
#141065357Monday, July 21, 2014 4:27 PM GMT

That probably means that the script runs right at the creation of the server.
RealistK
#141079395Monday, July 21, 2014 6:59 PM GMT

hmm, how to fix?
CWRA0444
#141079686Monday, July 21, 2014 7:02 PM GMT

add a wait(2) before everything
RealistK
#141098915Monday, July 21, 2014 10:03 PM GMT

everything..?
brinkokevin
#141099570Monday, July 21, 2014 10:09 PM GMT

lol i remember when i was creating rpg i had same error brb

    of     1