I'm creating a follow script but it's saying "Vector3 expected, got number" even if there is a Vector3.
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) local enemy = game.Workspace:WaitForChild("Chef") wait(1) follow = false while true do if Character.UpperTorso ~= nil then if Character.UpperTorso.Position - enemy.Torso.Position.X <= Vector3.new(10,0,0) then follow = true end end if follow then enemy.Humanoid.WalkToPoint = Character.UpperTorso.Position.X end wait(0.5) end end) end)
Character.UpperTorso.Position - enemy.Torso.Position.X
Your trying to subtract a number from a vector3 value so no what u did > Vector3.new(2,2,2) + 4
WalkToPoint of Humanoid requires a vector3 to walk to. You are giving it the X component of UppterTorso's Position.
To fix this just give it the actual position.
Also you are subtracting a number from a Vector3 position, lets instead subtract the actual position and use .Magnitude to check if it less than 10 studs away.
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) local enemy = game.Workspace:WaitForChild("Chef") wait(1) follow = false while true do if Character.UpperTorso ~= nil then if (Character.UpperTorso.Position - enemy.Torso.Position).Magnitude <= 10 then follow = true end end if follow then enemy.Humanoid.WalkToPoint = Character.UpperTorso.Position end wait(0.5) end end) end)