Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Problem with Humanoid AI?

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!!!!!!!!

2 comments

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.

0

srry bout that. Hope it help!

2 answers

✓ Accepted answer

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


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.

2 comments

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() )

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.