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
 

How do you make a humanoid run away from a part's position?

Previous Thread :: Next Thread 
br45entei is not online. br45entei
Joined: 06 Nov 2010
Total Posts: 1058
30 May 2012 10:50 AM
This is what I have, but it doesn't always work:

    local target = GetOffendersTorso()
    if target ~= nil then
        x_or_y = math.random(1, 2)
        if x_or_y == 1 then x_or_y = true elseif x_or_y == 2 then x_or_y = false end
        vec = Torso.Poition + Vector3.new(Torso.Position.X - target.Position.X, Torso.Position.Y - target.Position.Y, Torso.Position.Z - target.Position.Z) + Vector3.new(math.random(-5, 5), math.random(), math.random(-5, 5))
        Human:MoveTo(vec, target)

(This is not the whole script, just the part that runs away.)

~entei~
Report Abuse
br45entei is not online. br45entei
Joined: 06 Nov 2010
Total Posts: 1058
30 May 2012 10:56 AM
(I also don't like the negative WalkSpeed method, because running backwards seems weird.)

~entei~
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
30 May 2012 11:01 AM
BotTorso = balhh
TargetTorso = blahh
n = blahhh

direction = (BotTorso.Position-TargetTorso.Position).unit
Humanoid:MoveTo(BotTorso.Position+direction*n,TargetTorso)
Report Abuse
GradientZ is not online. GradientZ
Joined: 26 Apr 2012
Total Posts: 2173
30 May 2012 11:01 AM
You do not need the negative WalkSpeed.


Are you sure it is the exact position in the database? (CILENT)

Make the character scurry away at over 20 WALKSPEED, and it will manage to go through a brick.


~Say WUUUT?~
Report Abuse
br45entei is not online. br45entei
Joined: 06 Nov 2010
Total Posts: 1058
30 May 2012 11:01 AM
Is no one replying because of the stupid 'Your post can only contain 60 characters'? Just delete the 'Re: ' ...

~entei~
Report Abuse
br45entei is not online. br45entei
Joined: 06 Nov 2010
Total Posts: 1058
30 May 2012 11:03 AM
^ Yes, As I said, I don't want negative Walkspeed, I want the opposite direction of a part's position!

~entei~
Report Abuse
br45entei is not online. br45entei
Joined: 06 Nov 2010
Total Posts: 1058
30 May 2012 11:04 AM
@ su8;

In:
`BotTorso = balhh
TargetTorso = blahh
n = blahhh
direction = (BotTorso.Position-TargetTorso.Position).unit
Humanoid:MoveTo(BotTorso.Position+direction*n,TargetTorso)`

What does `n` need to be?

~entei~
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
30 May 2012 11:05 AM
Opposite direction is always

-(direction)
Report Abuse
GradientZ is not online. GradientZ
Joined: 26 Apr 2012
Total Posts: 2173
30 May 2012 11:05 AM
Cannot help you there.
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
30 May 2012 11:05 AM
>What does `n` need to be?

n doesn't really matter if the humanoids walks n studs in less than the time when it calls the MoveTo function again..

It's just the distance to that direction
Report Abuse
br45entei is not online. br45entei
Joined: 06 Nov 2010
Total Posts: 1058
30 May 2012 11:23 AM
su8, I tried yours and the humanoid just stands there... I know Everything else is setup right, and I'm not getting any output.

~entei~
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
30 May 2012 11:41 AM
Show me the script you used.. Because you need to modify mine..
Report Abuse
br45entei is not online. br45entei
Joined: 06 Nov 2010
Total Posts: 1058
01 Jun 2012 06:26 AM
zombie = script.Parent.Zombie
Torso = script.Parent.Torso
n = 1 --???

while wait() do
    target = game.Workspace.Brick
    if target ~= nil then
        direction = (Torso.Position - target.Position).unit
        zombie:MoveTo(Torso.Position + direction*n, target)
        zombie.WalkSpeed, zombie.Parent.Attacking.Value = 10, true
    else zombie.WalkSpeed, zombie.Parent.Attacking.Value = 1, false
    end
end
--[[End Test Successful!]]

~entei~
Report Abuse
br45entei is not online. br45entei
Joined: 06 Nov 2010
Total Posts: 1058
01 Jun 2012 07:07 AM
Oh, I got it now! I found that if I make `n = 5` then the zombie runs away! Thanks.

~entei~
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