Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Problem with Humanoid AI?

Asked by 9 years ago

I need some help with this script. PLSS!

player = game.Players.LocalPlayer.Character.Torso.CFrame.p  --the script is a local one, and is located in the StarterPlayerScripts file
print(player)
repeat
wait(.1)
human = game.Workspace.Dummy --dummy stands for the humanoid model
human.Humanoid.WalkToPoint = Vector3.new(player)
until human==nil

The problem is the humanoid keeps walking to the 0,0,0 position in the map when the player joins. But when you specify the humanoids WalkToPoint as a number, rather than a variable it works. HALP!!!!!!!!

0
Place your code into a code block by clicking the icon with the picture of the lua logo. It would make the code easier to read for us. Alpha_Toon 57 — 9y
0
srry bout that. Hope it help! LateralLace 297 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

It looks like player is already in a vector try doing

player = game.Players.LocalPlayer.Character.Torso.CFrame.p  --the script is a local one, and is located in the StarterPlayerScripts file
print(player)
repeat
wait(.1)
human = game.Workspace.Dummy --dummy stands for the humanoid model
human.Humanoid.WalkToPoint = player
until human==nil


Ad
Log in to vote
0
Answered by 9 years ago

You have a few issues here

player is already a Vector3 value. Don't do that.

The value of player is not going to change. You may want to consider instead setting a variable to be the Torso and making the AI move to the Torso.Position

All players are trying to control this one single dummy Humanoid, over a network. Bad idea. Move it to a server script and choose a Player to pick on.

0
Oh and this was just to test a local ai or the humanoid. So then if I were to add this to server scripts, how would you locate a player that is the closest to the humanoid. Basicly the humanoid would target the closest player, and then would lock on to that player until a certain event fired (ex. died() ) LateralLace 297 — 9y
0
Search through the Players and choose the closest one (The one with the smallest magnitude from torso to torso), and set a value when the Player's Humanoid dies so that the loop can break and the AI can choose a new target. User#6546 35 — 9y

Answer this question