I have this one SFing AI, and he has three basic moves: Spinning, running towards someone, or just following them and hurting them. Okay, so, the problem is, is that whenever he spins, he spins but then he just stands in the position he's in and doesn't move at all. The only time he moves is when he spins again. So here's the technique script: (And don't mind all of the values it reffers to, those probably don't matter)
while true do
wait(0.1)
while script.Parent.Parent.IsFollowing.Value == 1 do
print("Loaded moves...")
wait(0.5)
local move = (math.random(1, 3))
if script.Parent.Parent.IsFollowing.Value == 1 then
if move == 2 then
print("Spinning...")
script.Parent.Parent.Spinning.Value = 1
script.Parent.Parent.Sword.Slashing.Value = 1
h = script.Parent.Parent.Humanoid
h:MoveTo(Vector3.new(script.Parent.Parent.Torso.Position.x-1), script.Parent.Parent.Torso)
wait(0.1)
h:MoveTo(Vector3.new(script.Parent.Parent.Torso.Position.x-1), script.Parent.Parent.Torso)
wait(0.1)
h:MoveTo(Vector3.new(script.Parent.Parent.Torso.Position.z-1), script.Parent.Parent.Torso)
wait(0.1)
h:MoveTo(Vector3.new(script.Parent.Parent.Torso.Position.z-1), script.Parent.Parent.Torso)
wait(0.1)
h:MoveTo(Vector3.new(script.Parent.Parent.Torso.Position.x, script.Parent.Parent.Torso.Position.y, script.Parent.Parent.Torso.Position.z), script.Parent.Parent.Torso)
script.Parent.Parent.Sword.Slashing.Value = 0
script.Parent.Parent.Spinning.Value = 0
if script.Parent.Parent.Humanoid.Health < 1 then
print("Robot died")
script.Parent.Parent.IsFollowing.Value = 0
script.Parent.Parent.Name = "OOF!"
end
if script.Parent.Parent.PlayerDeadValue.Value == 1 then
print("Player died")
script.Parent.Parent.IsFollowing.Value = 0
script.Parent.Parent.Name = "Nice job, but I got you."
end
move = (math.random(1, 3))
end
end
print("Lunging...")
if script.Parent.Parent.IsFollowing.Value == 1 then
if move == 3 then
script.Parent.Parent.Name = "YAAAA!"
script.Parent.Parent.Humanoid.WalkSpeed = 32
script.Parent.Parent.Sword.Lunging.Value = 1
wait(1.5)
script.Parent.Parent.Sword.Lunging.Value = 0
script.Parent.Parent.Humanoid.WalkSpeed = 18
script.Parent.Parent.Name = "Fighter Bot"
if script.Parent.Parent.Humanoid.Health < 1 then
print("Robot died")
script.Parent.Parent.IsFollowing.Value = 0
script.Parent.Parent.Name = "OOF!"
end
if script.Parent.Parent.PlayerDeadValue.Value == 1 then
print("Player died")
script.Parent.Parent.IsFollowing.Value = 0
script.Parent.Parent.Name = "Nice job, but I got you."
end
move = (math.random(1, 3))
end
end
if script.Parent.Parent.IsFollowing.Value == 1 then
if move == 1 then
print("Move == 1, nothing happend")
if script.Parent.Parent.Humanoid.Health < 1 then
print("Robot died")
script.Parent.Parent.IsFollowing.Value = 0
script.Parent.Parent.Name = "OOF!"
end
if script.Parent.Parent.PlayerDeadValue.Value == 1 then
print("Player died")
script.Parent.Parent.IsFollowing.Value = 0
script.Parent.Parent.Name = "Nice job, but I got you."
end
move = (math.random(1, 3))
end
end
end
wait(0.1)
if script.Parent.Parent.IsFollowing.Value == 0 then
print("IsFollowing equals zero!")
end
end
And just in case, here is the script where he follows you:
debounce = false
function onTouch(part)
local humanoid = part.Parent:findFirstChild("Humanoid")
if (humanoid ~=nil) then
if debounce == false then
debounce = true
script.Parent.Parent.IsFollowing.Value = 1
script.Parent.Parent.PlayerName.Value = part.Parent.Name
local torso = part.Parent:findFirstChild("Torso")
while script.Parent.Parent.Spinning.Value ~= 1 do
bin = script.Parent
h = script.Parent.Parent.Humanoid
Torso = script.Parent.Parent.Torso
base = game.Workspace.Base
h:MoveTo(torso.Position, (workspace.Base))
wait(0.1)
h:MoveTo(Vector3.new(Torso.Position.x, Torso.Position.y, Torso.Position.z), Torso)
end
end
end
end
script.Parent.Touched:connect(onTouch)
Alright, so, he just stands there after a spin. It's all he does, except for him doing another spin. Please, help? |