I created a model called Golem and I rigged it correctly (I'm pretty sure) and I made an animation for it which is just a basic walking animation. I am using most of the scripts and values that can be found in the AI Enemy model in the tool box. I modified the follow script so that it played my animation when it moved. The issue is that the Golem doesn't move. I know for a fact that it is running through he line of code that tells it to move with no error since no errors pop up and because it runs the next lines. I did a compared this version of the Golem to an earlier one I made that moves without the animation (and the earlier version does move, it just doesn't have the animation which means that the animation is causing the problem) and the only difference I found was that the Golem that moved had it's Root Part property set to Torso and the one that doesn't move yet plays the animation has it's Root Part property set to HumanoidRootPart (The Root Part property is in the Humanoid object in the Model). Here is my code that tells it to follow:
`local larm = script.Parent:FindFirstChild("Left Arm") local rarm = script.Parent:FindFirstChild("Right Arm") local isplaying = false local GolemWalkAnim = game.Workspace.GolemWalk local animTrack = script.Parent.Enemy:LoadAnimation(GolemWalkAnim) function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = 20 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") 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 end return torso end function walk() if isplaying == false then animTrack:Play() isplaying = true AnimationCooldown() end end function AnimationCooldown() wait(1.1) isplaying = false end while true do wait(0.1) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then script.Parent.Enemy:MoveTo(target.Position) animTrack:Play() walk() end end
I copied this code and put it into the follow script in the other Golem (the one without the animation but it moves) and it still moved but it just didn't play the animation (I'm guessing it didn't play the animation because it wasn't rigged. It also doesn't have a HumanoidRootPart) So my final question is, what am I doing wrong? My goal is to make an enemy named Golem that follows the closest player and plays a walking animation while its following that player. Sorry for the long post but I wanted to be as detailed as possible.
remove the ` in the very first line of the script in the beginning