of     1   

MisterScripter
#63441211Saturday, February 25, 2012 10:38 PM GMT

This script is suppose to check if the human that is closest to the AI is friendly (same team) or an enemy (other team). It seems to have an error that I cannot resolve and I need your help. I want the AI to go after Enemies that are on the 'Red' Team and not chase humanoids who are on the Same team. ------------------------------------------------ My Script local larm = script.Parent:FindFirstChild("Left Arm") local rarm = script.Parent:FindFirstChild("Right Arm") function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = 50 local temp = nil local human = nil local temp2 = nil for x = 1, #list do temp2 = list[x] if (temp2.className == "Model") and (temp2 ~= script.Parent) then temp = temp2:findFirstChild("Torso") human=temp2:FindFirstChild('Humanoid') or temp2:FindFirstChild('RedTeam') or nil if GetPlayerFromCharacter(temp2.Parent).TeamColor == game.Teams.Reds.TeamColor then -----THIS PART IS BROKEN!!!! if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then if (temp.Position - pos).magnitude < dist then torso = temp dist = (temp.Position - pos).magnitude end end end return torso else findNearestTorso(script.Parent.Torso.Position) end end end while true do wait(0.1) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then script.Parent.RedTeam:MoveTo(target.Position, target) end end ------------------------------------- Output: Workspace.RedMinion.FollowScript:16: attempt to call global 'GetPlayerFromCharacter' (a nil value) ------------------------------------- Can you fix my script?
rangersmash
#63441347Saturday, February 25, 2012 10:40 PM GMT

[ Content Deleted ]
kingkiller1000
#63441362Saturday, February 25, 2012 10:40 PM GMT

Game.Players:GetPlayerFromCharacter
rangersmash
#63441389Saturday, February 25, 2012 10:41 PM GMT

[ Content Deleted ]
MisterScripter
#63441512Saturday, February 25, 2012 10:43 PM GMT

Now im getting this error after using this script rangersmash... 17:41:42 - Workspace.RedMinion.FollowScript:15: attempt to index a nil value 17:41:42 - Script "Workspace.RedMinion.FollowScript", Line 15 - global findNearestTorso 17:41:42 - Script "Workspace.RedMinion.FollowScript", Line 31 17:41:42 - stack end
MisterScripter
#63441562Saturday, February 25, 2012 10:44 PM GMT

Im in solo play testing my scripts out...
MisterScripter
#63442387Saturday, February 25, 2012 10:59 PM GMT

Help Bump*
MisterScripter
#63562478Tuesday, February 28, 2012 2:39 AM GMT

2nd Help Bump*
xXxMoNkEyMaNxXx
#63571774Tuesday, February 28, 2012 7:51 AM GMT

you say or nil, that's why it's attempting to index a nil value.
xXxMoNkEyMaNxXx
#63571781Tuesday, February 28, 2012 7:52 AM GMT

you should have it so that it only indexes it if it's there.
blueymaddog
#63572695Tuesday, February 28, 2012 10:56 AM GMT

*cough* obviously copied and then slightly modified from the free model zombie follow script *cough*
ScriptOn
#79447759Friday, October 05, 2012 12:22 AM GMT

[ Content Deleted ]

    of     1