|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 27 Mar 2015 08:23 PM |
but using moveto will teleport them will it not?
|
|
|
| Report Abuse |
|
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 27 Mar 2015 08:28 PM |
| Why did you put 25, 25, 25? It should just be 25. |
|
|
| Report Abuse |
|
|
|
| 27 Mar 2015 08:29 PM |
| Also it should be <= not =< |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 27 Mar 2015 08:31 PM |
it comes up with a red line under
if player:DistanceFromCharacter <= 25 then
<= |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|