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: Move char towards char

Previous Thread :: Next Thread 
CardsOfFate is not online. CardsOfFate
Joined: 08 Jul 2014
Total Posts: 761
27 Mar 2015 08:21 PM
How would I find everyone within 50 studs of my character and move them towards my torso?
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
27 Mar 2015 08:23 PM
Table through every thing in workspace
Check if there's a humanoid
then use Humanoid:MoveTo
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
27 Mar 2015 08:23 PM
http://wiki.roblox.com/index.php?title=API:Class/Player/DistanceFromCharacter

And what do you mean by "move them towards my torso"? Teleport them? Make them walk?
Report Abuse
CardsOfFate is not online. CardsOfFate
Joined: 08 Jul 2014
Total Posts: 761
27 Mar 2015 08:23 PM
but using moveto will teleport them will it not?
Report Abuse
CardsOfFate is not online. CardsOfFate
Joined: 08 Jul 2014
Total Posts: 761
27 Mar 2015 08:24 PM
make them walk ^^
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
27 Mar 2015 08:25 PM
Humanoid:MoveTo will make them walk towards the destination.
Report Abuse
CardsOfFate is not online. CardsOfFate
Joined: 08 Jul 2014
Total Posts: 761
27 Mar 2015 08:26 PM
Thanks,

for _, player in pairs(game.Players:GetPlayers()) do
if player:DistanceFromCharacter =< 25, 25, 25 then

end
end

I take it I've done this wrong e.e
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
27 Mar 2015 08:28 PM
Why did you put 25, 25, 25? It should just be 25.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
27 Mar 2015 08:29 PM
Also it should be <= not =<
Report Abuse
Septamology is not online. Septamology
Joined: 20 Jun 2013
Total Posts: 2811
27 Mar 2015 08:31 PM
Alright, let's see.



local yourplayer = YOURPLAYERNAMEHERE

for _, p in pairs(game.Players:GetPlayers()) do
if p.Character ~= nil and p.Name ~= game.Players:FindFirstChild(yourplayer).Name then
if (p.Character.Torso.Position - game.Players:FindFirstChild(yourplayer).Character.Torso.Position).magnitude <= 50 then
p.Character.Humanoid:MoveTo(game.Players:FindFirstChild(yourplayer).Character.Torso)
end
end
end


Hope this helps :)
Report Abuse
CardsOfFate is not online. CardsOfFate
Joined: 08 Jul 2014
Total Posts: 761
27 Mar 2015 08:31 PM
it comes up with a red line under

if player:DistanceFromCharacter <= 25 then


<=
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
27 Mar 2015 08:33 PM
You have to put () when calling a function or method. So it should be :DistanceFromCharacter() not :DistanceFromCharacter
Report Abuse
CardsOfFate is not online. CardsOfFate
Joined: 08 Jul 2014
Total Posts: 761
27 Mar 2015 08:35 PM
@Sept

Is that post to be in a localscript or a script?

I'm getting an error:

Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Run = game:GetService("RunService")
enable = false

Mouse.Button1Down:connect(function()
if enable == false then
enable = true
local yourplayer = Player

for _, p in pairs(game.Players:GetPlayers()) do
if p.Character ~= nil and p.Name ~= game.Players:FindFirstChild(yourplayer).Name then
if (p.Character.Torso.Position - game.Players:FindFirstChild(yourplayer).Character.Torso.Position).magnitude <= 50 then
p.Character.Humanoid:MoveTo(game.Players:FindFirstChild(yourplayer).Character.Torso)
end
end
end
end
end)

on the linke that saids if p.Character ~= nil

to index a nil value
Report Abuse
CardsOfFate is not online. CardsOfFate
Joined: 08 Jul 2014
Total Posts: 761
27 Mar 2015 08:42 PM
bump I guess.
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