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: NPC move-to refuses to budge

Previous Thread :: Next Thread 
DankosaurusReks is not online. DankosaurusReks
Joined: 21 Jul 2012
Total Posts: 67
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
ColonySimulator is not online. ColonySimulator
Joined: 05 Jul 2015
Total Posts: 1721
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
ColonySimulator is not online. ColonySimulator
Joined: 05 Jul 2015
Total Posts: 1721
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 is not online. 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
DankosaurusReks is not online. DankosaurusReks
Joined: 21 Jul 2012
Total Posts: 67
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
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
12 Apr 2016 04:35 PM
ok what u are trying to do in that script ^ makes no sense
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
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
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
12 Apr 2016 04:44 PM
why does it help to use the NPC's torso as the second argument?????
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
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
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
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
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
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
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