this script will not make my enemy follow me at all so I didn't ever finish the dmg part cause the follow script was broken any one know the error? the script is in workspace btw EDITED ok so I realized I cant have a string for the enemy because of the script itself so I change the script and still doesn't work but I got a differnent out put too
script
wait(1) follow = false while true do if game.Players.Player1.Character.Torso ~= nil then if game.Players.Player1.Character.Torso.Position - game.Workspace.PotatoMan.Torso.Position.X <= 10 then follow = true end end if follow then game.Workspace.PotatoMan.Humanoid.WalkToPoint = game.Players.Player1.Character.Torso.Position.X end wait(0.5) end
output
20:49:12.265 - Client(1) Server(0) 20:49:16.108 - Workspace.Script:6: bad argument #2 to '?' (Vector3 expected, got number) 20:49:16.109 - Stack Begin 20:49:16.111 - Script 'Workspace.Script', Line 6 20:49:16.112 - Stack End
Because.. at line 06, you did
game.Workspace.PotatoMan.Torso.Position.X <=10
The problem being is,
<=10
If you REALLY can't understand for some reason (the error should've explained it to you just fine), then I'll explain it. It was expecting Vector3, and you gave it a number.
The number is 10. It wasn't expecting that, therefore it doesn't work.
How to fix it: You should be able to fix it already, because I was told not to provide a full answer, but I'll be nice this time.
game.Workspace.PotatoMan.Torso.Position.X <= Vector3.new(10,0,0)
The reason why I did Vector3.new(10,0,0) instead of Vector3.new(0,10,0) or Vector3.new(0,0,10) is because, it's formatted as X,Y,Z. You used Position.X, so I have to use X as well. Now, I hoped I helped, but I can't just give you the answer and go, I recommend using magnitude.
This works very well, and can be planned / sorted on a grid. Region3 works well too, but it seems it would be too complicated for someone who can't solve this error (no offense!).
Here's how magnitude would work:
wait(1) follow = false while true do if game.Players.Player1.Character.Torso ~= nil then if (game.Players.Player1.Character.Torso.Position - game.Workspace.PotatoMan.Torso.Position).magnitude < 10 then follow = true end end