|
| 11 Apr 2016 07:42 PM |
while true do wait(1) script.Parent.Humanoid:MoveTo(Vector3.new(workspace.Player.Torso.Position)) wait(1) end
--apparently refused to move to my current position after looping --only doing this script experimentally in roblox studio for my character, not sure if that is the issue |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2016 07:49 PM |
It's normal because the game might not be recognizing the statement "Player" since you can have different player name. I'm sorry if my script are a bit harsh.
Part = Script.Parent
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local Master = Instance.new("StringValue",Part) Master.Name = "Master" Master.Value = player.Name end) end)
while wait() do wait(1) if Part:FindFirstChild("Master") then local Master = Part:FindFirstChild("Master") local PlayerIG = game.Workspace:FindFirstChild(Master.Value) local T = PlayerIG:FindFirstChild("Torso") script.Parent.Humanoid:MoveTo(T.Position) end |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2016 07:50 PM |
My bad I realised that I made two error in my previous script.
Part = script.Parent
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local Master = Instance.new("StringValue",Part) Master.Name = "Master" Master.Value = player.Name end) end)
while wait() do wait(1) if Part:FindFirstChild("Master") then local Master = Part:FindFirstChild("Master") local PlayerIG = game.Workspace:FindFirstChild(Master.Value) local T = PlayerIG:FindFirstChild("Torso") script.Parent.Humanoid:MoveTo(T.Position) end end |
|
|
| Report Abuse |
|
|
unroot
|
  |
| Joined: 18 Sep 2009 |
| Total Posts: 1114 |
|
|
| 11 Apr 2016 08:02 PM |
that's so much work for such a small task, don't over complicate it so much ^
also was there anything in the output?
#code print("yolo" .. string.rep("o", math.huge)) |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 04:23 PM |
I saw what both of you guys wrote and I tried this:
while true do wait(1) script.Parent.Humanoid:MoveTo(Vector3.new(game.Players.LocalPlayer.Character.Torso.Position)) wait(1) end
-- Moves once but does nothing afterward, no output or anything ;p -- |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 04:35 PM |
| ok what u are trying to do in that script ^ makes no sense |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 04:40 PM |
when you use MoveTo() on a humanoid it usually helps to add the NPC's basepart as a second argument
also a part's position is already a vector3 so you dont need the Vector3.new()
script.Parent.Humanoid:MoveTo(workspace.Player.Torso.Position,script.Parent.Torso) |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 04:44 PM |
| why does it help to use the NPC's torso as the second argument????? |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 04:45 PM |
sorry, i meant use a part in Player as the second parameter, not the npc.
script.Parent.Humanoid:MoveTo(workspace.Player.Torso.Position,workspace.Player.Torso) |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 04:46 PM |
| You can have it so that if the player moves, the npc's path will adjust to continue moving toward's the player, instead of an empty space. |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 04:48 PM |
| yeah if u set the second argument to the player's torso then the npc will always follow the torso and auto adjust |
|
|
| Report Abuse |
|
|